davidmarkclements / fast-safe-stringify

Safely and quickly serialize JavaScript objects
MIT License
348 stars 27 forks source link

global/shared arr object doesn't work well in parallel environment #35

Closed marbemac closed 6 years ago

marbemac commented 6 years ago

Something that we've noticed is that the arr value is shared globally.

https://github.com/davidmarkclements/fast-safe-stringify/blob/master/index.js#L6

We run a bunch of low priority processes in parallel that all use safeStringify and have built in "pauses" to allow other high priority processes to use the main thread. This is leading to odd behavior since all the safeStringify's use the same arr object. There are a number of potential solutions to this that we could help to implement, but curious if you have any thoughts or preferred approaches?

mcollina commented 6 years ago

How have you built in pauses? The full execution of this is synchronous. Do you have a broken test?

marbemac commented 6 years ago

You're right, this issue actually might actually be attributable to a different bit of our implementation. Will close for now and re-open with example broken tests if we're able to pinpoint the issue.