Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

strange sandbox behavior with mongoose #9

Closed
ericchaves opened this Issue · 2 comments

3 participants

Eric Paschoalick Chaves Domenic Denicola moizr
Eric Paschoalick Chaves

Hi Felix,

I'm facing a very odd behavior that I can't track down due to my beginner level on node.js. I use mocha to test my code and your's sandboxed-module (https://github.com/felixge/node-sandboxed-module) for dependency injection in some required modules for the code I'm testing.

Whenever I load a module that uses mongoose inside a sandbox all mongoose calls like model.save or model.find times-out unless I load the module twice. For example, in a piece of code like this (chopped for clarity):

    var User = sandbox.require('../../models/users', {
        requires: { // define some mocks... }
    });

    User = require('../../models/users');   

    var user = new User(user_data);
        user.save(function(err, doc){
            //do something on callback
    });

Without the User = require('../../models/users') the user.save call goes away and never callbacks. Including it makes everything works and the model class stils have the mocks injected just as if it was loaded by the sandbox.require call.

Have you heard about this before? Am I doing something wrong here?

Thanks for any help.

Domenic Denicola
Collaborator

If this is still a problem, let me know, and we'll be sure to look into it!

Domenic Denicola domenic closed this
moizr

I'm facing a similar problem. When I use sandboxed module to require a module - mongoose seems to timeout. @ericchaves if you found a solution to the problem please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.