async-json icon indicating copy to clipboard operation
async-json copied to clipboard

Thread safety when JSON.stringifyAsync

Open mohsen1 opened this issue 10 years ago • 1 comments

Mostly from https://github.com/nodejs/io.js/issues/2031#issuecomment-114347314

Consider following code:

let obj = {foo: 1};
JSON.stringifyAsync(obj, result => console.log(result));
delete obj.foo

There could be a thread collision issue here. What can be done?

mohsen1 avatar Aug 02 '15 05:08 mohsen1

JS is single-threaded. While an implementation may choose to implement it in that way, they'd have to ensure that observable semantics didn't conflict with that. Thus, any mention of threading in the spec is unlikely to pass muster.

ljharb avatar Aug 02 '15 06:08 ljharb