Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid problems when required twice #76

Closed
wants to merge 1 commit into from

Conversation

vbfox
Copy link

@vbfox vbfox commented Apr 27, 2017

It's possible due to test runners like jest playing with the node runtime object.

The native module can't be required twice but the javascript one can. As the javascript one return a mutated version of the native one it create problems :

exports._writePointer = exports.writePointer

exports.writePointer = function writePointer (buf, offset, ptr) {
  debug('writing pointer to buffer', buf, offset, ptr)
  exports._writePointer(buf, offset, ptr)
  exports._attach(buf, ptr)
}

After 2+ executions of this code writePointer would call itself and produce a stack overflow exception.

Additional info

Possible due to test runners like jest playing with the node runtime
object.
@vbfox vbfox closed this Sep 11, 2017
sa-MatteoHausner added a commit to sa-MatteoHausner/ref that referenced this pull request May 29, 2019
prevent infinite recursions
sa-MatteoHausner added a commit to sa-MatteoHausner/ref that referenced this pull request Oct 28, 2019
prevent infinite recursions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant