GithubHelp home page GithubHelp logo

Comments (16)

gnarf avatar gnarf commented on September 27, 2024

Basically doing this:

cd node_modules/webpack/node_modules/node-libs-browser ; npm i [email protected]

Is how I'm fixing it right now, and it works.

from node-libs-browser.

sokra avatar sokra commented on September 27, 2024

This should propably be fixed in simon or bluebird... Am I right?

from node-libs-browser.

gnarf avatar gnarf commented on September 27, 2024

Perhaps, but I think this is an artifact coming from the "browserifying" of it. The process.nextTick implementation in process could hold onto the "real" setTimeout and call it. Or maybe bluebird could do a better job of detecting fake node "process" and revert back to using mutation observers? CC @petkaantonov

from node-libs-browser.

gnarf avatar gnarf commented on September 27, 2024

For reference https://github.com/defunctzombie/node-process/blob/master/browser.js#L28 is the cause of the problem -- the old version in 0.8.0 used a much more clever way that avoided calling the sinon fake timer here: https://github.com/defunctzombie/node-process/blob/v0.8.0/browser.js#L14

from node-libs-browser.

petkaantonov avatar petkaantonov commented on September 27, 2024

maybe bluebird could do a better job of detecting fake node "process"

I don't think this is the issue given https://github.com/petkaantonov/bluebird/blob/master/src/util.js#L280-L281

from node-libs-browser.

benjamingr avatar benjamingr commented on September 27, 2024

Also worth mentioning you can always tell bluebird explicitly how to schedule via Promise.setScheduler - although like Petka said it's not bluebird misdetecting here.

from node-libs-browser.

gnarf avatar gnarf commented on September 27, 2024

@petkaantonov then why does installing process 0.8.0 again inside the webpack deps fix the problem?

from node-libs-browser.

sokra avatar sokra commented on September 27, 2024

@gnarf can you provide a test case so we can play around with it?

from node-libs-browser.

petkaantonov avatar petkaantonov commented on September 27, 2024

I didn't look into the real issue here, I was just pointing out that recent versions of bluebird check for authentic process object that cannot be faked without access to native v8 api.

from node-libs-browser.

gnarf avatar gnarf commented on September 27, 2024

Oh - when did that check get added? Perhaps I'm still behind on bluebird somewhere.

FWIW this test case fails:

/* global sinon */
require('script!sinon/pkg/sinon');

describe.only('faketime', function() {
  var timers;
  beforeEach(function() {
    timers = sinon.useFakeTimers();
  });
  afterEach(function() {
    timers.restore();
  });
  it('can resolve a promise', function() {
    return require('bluebird').resolve();
  });
});

from node-libs-browser.

petkaantonov avatar petkaantonov commented on September 27, 2024

It's in 2.9.6+

from node-libs-browser.

sokra avatar sokra commented on September 27, 2024

sinon fake timers do stop process.nextTick until you call timers.tick(ms), if I get the documentation correctly...

from node-libs-browser.

gnarf avatar gnarf commented on September 27, 2024

Except that same test passes with process 0.8.0 instead of 0.10.0 --- it also passes with bluebird 2.9.13+ - so I think I know the answer -- dependency hunt time to figure out what isn't up to date with bluebird

Sorry to take this up as an issue here instead of in bluebird! Thanks for the support @petkaantonov and @sokra

from node-libs-browser.

KidkArolis avatar KidkArolis commented on September 27, 2024

I'm running into the same issue with when.js + webpack + sinon.useFakeTimers - all promises seem to break. Does bluebird do something extra to detect it's not actually a node env @gnarf ?

from node-libs-browser.

gnarf avatar gnarf commented on September 27, 2024

Make sure to use latest bluebird?
On Apr 24, 2015 10:37 AM, "Karolis Narkevicius" [email protected]
wrote:

I'm running into the same issue with when.js + webpack +
sinon.useFakeTimers - all promises seem to break. Does bluebird do
something extra to detect it's not actually a node env @gnarf
https://github.com/gnarf ?


Reply to this email directly or view it on GitHub
#20 (comment)
.

from node-libs-browser.

gnarf avatar gnarf commented on September 27, 2024

Sorry, misread... Look at the scheduler code in bluebird. The node process
object has a special to string value so you can detect it is node
On Apr 24, 2015 10:38 AM, "Corey Frang" [email protected] wrote:

Make sure to use latest bluebird?
On Apr 24, 2015 10:37 AM, "Karolis Narkevicius" [email protected]
wrote:

I'm running into the same issue with when.js + webpack +
sinon.useFakeTimers - all promises seem to break. Does bluebird do
something extra to detect it's not actually a node env @gnarf
https://github.com/gnarf ?


Reply to this email directly or view it on GitHub
#20 (comment)
.

from node-libs-browser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.