FileSystemWritableFileStream.write causes quota error - javascript

I'm using File System Access API (https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API) to read and write a file into disk. This is my code;
const writable = await cacheFileHandle.createWritable({ keepExistingData: false });
await writable.write(JSON.stringify(cache));
await writable.close();
This code fails with Uncaught (in promise) DOMException: The operation failed because it would cause the application to exceed its storage quota. error. This began when the file reached 10MB. Is there any way to solve this?
Note:
I already tried the HTML File API solutions.
I tried window.webkitStorageInfo.requestQuota(window.PERSISTENT, 10240*10240,()=>{...},()=>{...}). That didn't work.
Another solution was to put unlimitedStorage to the manifest.json, but this is a react app, so that didn't help either.

Related

Using JS IPFS in the Browser?

I am developing a digital wallet and I am using ipfs inside a web extension, but I have the following errors:
this is my code:
const node = await Ipfs.create()
const results = await node.add('hello manlio')
document.getElementById('demo').innerHTML = JSON.stringify(results)
How to solve these errors ? thanks
I tried the following examples on ipfs: https://github.com/ipfs-examples/js-ipfs-examples
There are a few potential issues that could cause errors in this code:
Make sure that the IPFS library is correctly imported and available in your code. You can do this by adding the following line at the top of your code:
import Ipfs from 'ipfs';
Make sure, also, that the element with the ID 'demo' exists in the HTML document. If it does not exist, the following line of code will throw an error:
document.getElementById('demo').innerHTML = JSON.stringify(results) .
If you are running this code in a web browser, you may need to handle any potential CORS (Cross-Origin Resource Sharing) errors. You can do this by serving your HTML file from a local web server, or by using a CORS proxy.

Moodle: Javascript errors preventing SCORM package loading?

I'm new here and having some issues on my Moodle site through which I provide online training. We upload SCORM packages to the Moodle and recently have had an issue which is stopping the SCORM packages from loading or sometimes just taking a very long time to load.
We receive the SCORM error that the "SCORM player has determined that your internet connection is unreliable or has been interrupted. If you continue in the SCORM activity, your progress may not be saved. You should exit the activity now and return when you have a dependable connection".
However, we have tried this from a number of different internet points and devices, with the same problem reoccurring. We therefore contacted our hosting provider, who replied:
"It appears the issue is coming from the fact that there are quite a few JavaScript errors on the site. I am pasting them below:
Failed to load resource: net::ERR_FAILED
chrome-extension://dliochdbjfkdbacpmhlcpmleaejidimm/cast_sender.js
Failed to load resource: net::ERR_FAILED
chrome-extension://enhhojjnijigcajfphajepfemndkmdlo/cast_sender.js
Failed to load resource: net::ERR_FAILED
chrome-extension://fmfcbgogabcbclcofgocippekhfcmgfj/cast_sender.js
Failed to load resource: net::ERR_FAILED
chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm/cast_sender.js
Failed to load resource: net::ERR_FAILED
chrome-extension://fjhoaacokmgbjemoflkofnenfaiekifl/cast_sender.js
Failed to load resource: net::ERR_FAILED 4jquery.js:5 Uncaught
TypeError: Cannot read property 'scrollHeight' of null(anonymous
function)
# jquery.js:5x.extend.access
# jquery.js:3x.fn.(anonymous function)
# jquery.js:5e # content-script.js:1d
# content-script.js:1(anonymous function)
# content-script.js:1"
Can anyone assist and help me identify what the problem is that is causing the loading issues with my SCORM packages?
Kind regards
Eddie
I had the same issue with the message SCORM player has determined that your internet connection is unreliable or has been interrupted on all moodle servers, but the server is working fine and the work is saved correctly.
My solutions are two:
Set a bigger timeout (by default, moodle check internet connection with a 2 seconds timeout). You can set this parameter in 5, 7 or 10 seconds. You can set this value on lib/yui/src/checknet/js/checknet.js (search the request to a checknet.txt file)
Remove the checknet functionality. You can comment two lines on /mod/scorm/player.php. The lines you need to comment are these:
$PAGE->requires->string_for_js('networkdropped', 'mod_scorm');
$PAGE->requires->yui_module('moodle-core-checknet', 'M.core.checknet.init', array(array(
'message' => array('networkdropped', 'mod_scorm'),
)));
This is not a solution for a server that works wrong, this is a solution for a server that works fine but the time of the AJAX response is more than 2 seconds.
I don't believe that the first few (for cast_sender.js) are related to the issue at hand; cast_sender.js is a local script related to Chrome's ability to use Chromecast functionality. (Edit: The Google Cast SDK uses a rather "agricultural" method to detect if you're running Chrome with the appropriate extension; it's a known issue. Google chrome cast sender error if chrome cast extension is not installed or using incognito, https://code.google.com/p/google-cast-sdk/issues/detail?id=309)
The later lines they've pasted seem to bubble up from effectively a null pointer in whatever content_script.js is. Is the SCORM content locally produced? Do you know what software was used to create it - e.g. Articulate or Storyline? I presume that content_script.js is part of the player software?

WebSocket connection to <url> failed: Error during WebSocket handshake: Unexpected response code: 404

I' m new to WebSocket and Node.js. I'm trying to create a real-time chat as a basic program. I basically based my code here. I run my code in Amazon Linux for it to run as a real web server. I always got an error after I input the user's name.
I use node-static as a static server API for my index.html file.
Here's my code for my javascript: app.js
And here's my code for index.html located inside the "public" folder: index.html
I always get the error at line15 in index.html.
Can anyone tell me what is the problem there? I tried moving that part anywhere inside the connectToChat() function but the error is still there.
You have an error in url you call.
It have to be ws://<mywebserver>:8000
instead of ws://<mywebserver>:8000/index.html
To fix it, in index.html , change this line
var url = document.URL.replace("http://", "ws://");
to
var url = document.origin.replace("http://", "ws://");
I had the same issue. I was able to fix it by pointing the client script to the real IP. It is not the best solution, but it will do for the moment.
let socket = io('http://000.000.000.000:0000');
Hope it helps!

Does Valence javascript client libary work on localhost?

I've been experimenting with the Valence javaScript client library and the 'GettingStartedSample' download from D2L.
If the sample files are uploaded, accessed and ran from within a D2L course site the script works, however, if I try to run it from a localhost I run into a problem. On localhost I can successfully authenticate the application however when I try to run a 'Get Versions' or 'WhoAmI' request nothing happens.
Firebug tells me the following:
Object { readyState=0, status=0, statusText="error" } server.js (line 77)
error server.js (line 78)
(an empty string) (line 79)
Should I be able to make a request using the javascript client library from a localhost?
The short answer is yes, but you need to do some additional work.
I would advise reading up on the same origin policy so you have some background as to why XHRs (in your case, Valence calls) between domains do not work out of the box. The easiest thing to do is to use jsonp if all you are making are GET requests. If you need to make other requests, you will need to look into getting CORS support set up on your instance.

Microsoft JScript runtime error: Access is denied Dropbox.js in IE

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dropbox.js/0.9.0/dropbox.min.js"></script>
Hi am using above file to access dropbox functions. It contain all the dropbox functions. i included this one to my application and i
used the below code to upload a file to dropbox using writefile function.
This was working fine in chrome and Mozilla browser but in IE its getting an error.
The error is: "Microsoft JScript runtime error: Access is denied".
Please anyone help me how to resolve thid IE Error and tell me the reason why this error coming only for IE Browser?
var UploadToDropbox = new Dropbox.Client({ key: consumerKey, secret: consumerSecret, token: accessToken, tokenSecret: accessTokenSecret, dropbox: true });
UploadToDropbox.authenticate(function (error, UploadToDropbox) {
if (error) {
alert('Something wrong here.');
}
else {
UploadToDropbox.writeFile("HelloWorld.txt", "Hello, world!\n", function (error, stat) {
if (error) {
return showError(error); // Something went wrong.
}
alert("File saved to your dropbox successfully. ");
});
}
});
Hi thank you for your reply my question and i tried like that but still that same error coming.
Ok now what should i do for resolve this error.
and i tried with this also
<script type="text/javascript">
// Hack to make dropbox.js works in IE8, IE9.
if (!window.btoa) window.btoa = base64.encode;
if (!window.atob) window.atob = base64.decode;
</script>
but same error.
Open IE->Tools-->InternetOptions
In Security Tab->select Zone as Internet-->Click Custom Level Button---> Check "Enable" in Access data source across Domains under Miscellaneous.
It seems that IE does not play well with javascript events that trigger a DOM control. So try to remove such event actions , if they are present .
Usually means that you are attempting to update a property or access content that is not permitted under your current security settings.
Sometimes, it also happens due to usage of deprecated method .
The hack in your question is not necessary. dropbox.js packages its own implementation of atob / btoa, which is used on IE <= 9. You can try it out by accessing Dropbox.Util.atob and Dropbox.Util.atob in the IE Developer Tools console.
base64 code: https://github.com/dropbox/dropbox-js/blob/master/src/base64.coffee
First, please run the checkbox.js sample code to check your IE settings. If the sample works (you can log in, add tasks, mark them as done and remove them) then your IE settings are OK, and the problem is elsewhere.
checkbox.js: https://dl-web.dropbox.com/spa/pjlfdak1tmznswp/checkbox.js/public/index.html
Second, make sure that you're serving your HTML page using https://. The Dropbox API server uses https, and IE <= 9 doesn't allow cross-domain requests from http pages to https servers.
Third, you shouldn't need the token and tokenSecret parameters in the authorize call.
If you still get the JScript runtime error, can you please point to the line of code that causes it? Also, consider opening an issue on the dropbox.js GitHub page. This will get faster responses.

Categories