Svelte – list of bugs and their fixes

Correction of common errors on svelte.

TypeError: Object of type datetime is not JSON serializable

From the Python side, the data transfer is not correct. Data should be transmitted in json format.


json.dumps(my_dictionary, indent=4, sort_keys=True, default=str)


return json.dumps(last_price(name), separators=(‘,’, ‘:’))


return json.dumps(last_price(name))

Error: {#each} only iterates over array-like objects

We must explicitly declare that our variable will be an array:

Uncaught Error: {#each} only iterates over array-like objects.

[object Promise] svelte


index.mjs: 1569 Uncaught Error: {#each} only iterates over array-like objects.
at validate_each_argument (index.mjs: 1569)
at Object.update [as p] (App.svelte: 139)
at update (index.mjs: 707)
at flush (index.mjs: 676)
at init (index.mjs: 1439)
at new App (App.svelte: 120)
at app.js: 3
at app.js: 8

The solution will not necessarily be like the example below. There are many reasons that could be associated with this error.


The bottom line is that there is no time to receive data from the backend, which is then iterated on the Svelte side. At the moment when a variable in Svelte is initialized, there is still no data in it.

Add asynchrony to JS:

GeSHi Error: GeSHi could not find the language javasript (using path /home/admin/web/ (code 2)


We put the received data into an iterable data array, and not just into a variable:

let stocks = [[];
stocks = Arrayfrom(items[[1]);

Uncaught (in promise) SyntaxError: Unexpected token O in JSON at position 0 awate

Probably the data coming from the backend is not in JSON format. We fix:

return json.dumps(response)

Uncaught (in promise) TypeError: Failed to execute ‘json’ on ‘Response’: body stream is locked

If you try to read the response twice, then this error can occur. Those. code like this might throw an error:


In this case, you should remove the console.log and everything will work.

Similar Posts

Leave a Reply