Skip to content

Commit fb01a4e

Browse files
committed
Pyodide workaround due greedy properties access
THe issue is explained in here: pyscript/pyscript#2106 This MR adds reserved workers words to avoid creating forever pending promises all over the place. The list of words is `__dict__`, `constructor`, `get`, `has`, `includes`, `next`, `set` and `then`.
1 parent de009fb commit fb01a4e

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

docs/index.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

esm/workers.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ export const workers = new Proxy(new Map, {
88
},
99
});
1010

11-
export const workersHandler = new Proxy(workers, {
12-
get: (_, name) => workers[name].promise.then(w => w.sync),
11+
// filter out forever pending Promises in Pyodide
12+
// @issue https://github.com/pyscript/pyscript/issues/2106
13+
const ignore = new Set(['__dict__', 'constructor', 'get', 'has', 'includes', 'next', 'set', 'then']);
14+
15+
export const workersHandler = new Proxy(Object.freeze({}), {
16+
// guard against forever pending Promises in Pyodide
17+
// @issue https://github.com/pyscript/pyscript/issues/2106
18+
get: (_, name) => (typeof name === 'string' && !ignore.has(name)) ?
19+
workers[name].promise.then(w => w.sync) :
20+
void 0,
1321
});
1422
/* c8 ignore stop */

0 commit comments

Comments
 (0)