Giter VIP home page Giter VIP logo

Comments (15)

briancavalier avatar briancavalier commented on May 18, 2024

Ah, yes, that's definitely a case where I'd like it to rethrow the ReferenceError. I'll look into it. Thanks for the test case.

from when.

briancavalier avatar briancavalier commented on May 18, 2024

Hey @KidkArolis, I just merged a fix for this into the dev branch. Please give it a try and let me know if it works for you. If it looks good, then it'll get released as part of 1.5.1--probably early next week. Thanks!

from when.

KidkArolis avatar KidkArolis commented on May 18, 2024

That was quick!

Now, I think there are too many rethrows happening. I've used this dev branch in my app where I'm using when.all and several then's(), and what I get now is this output:

[object Promise 10] REJECTED: ReferenceError: iDontExist is not defined
debug.js:113
[object Promise 1.2.4.9] REJECTED: ReferenceError: iDontExist is not defined
debug.js:113
[object Promise 1.2.4.9] REJECTED: ReferenceError: iDontExist is not defined
debug.js:113
[object Promise 12] REJECTED: ReferenceError: iDontExist is not defined
debug.js:113
[object Promise 1.2.4.9] REJECTED: ReferenceError: iDontExist is not defined
debug.js:113
[object Promise 1.2.4.9.11] REJECTED: ReferenceError: iDontExist is not defined
debug.js:113
[object Promise 14] REJECTED: ReferenceError: iDontExist is not defined
debug.js:113
[object Promise 1.2.4.13] REJECTED: ReferenceError: iDontExist is not defined
debug.js:113
[object Promise 1.2.4.8] REJECTED: ReferenceError: iDontExist is not defined
debug.js:113
[object Promise 16] REJECTED: ReferenceError: iDontExist is not defined
debug.js:113
[object Promise 1.2.4.8] REJECTED: ReferenceError: iDontExist is not defined
debug.js:113
[object Promise 1.2.4.13.15] REJECTED: ReferenceError: iDontExist is not defined
debug.js:113
(8 times) Uncaught ReferenceError: iDontExist is not defined 

I'm thinking, because all of these rethrows originated from the same "error instance", maybe it would be possible to detect it's already been rethrown.

from when.

KidkArolis avatar KidkArolis commented on May 18, 2024

But I think even this is more useful then the silent failures.

from when.

briancavalier avatar briancavalier commented on May 18, 2024

Cool, thanks for testing it out. Yeah, def too many there--note the duplicated promise ids (1.2.4.8 and 1.2.4.9), too. I'll look into ways to tone it down a bit and post again when there's something new to try.

from when.

KidkArolis avatar KidkArolis commented on May 18, 2024

Hm.. it seems the dev branch altered the behaviour of my application. I'm not sure if this is due to the debug changes or something else.

from when.

KidkArolis avatar KidkArolis commented on May 18, 2024

Yeah, I've just tried master + updated debug.js and my app is behaving differently, so this new debug.js version is changing something, I'll try to see what exactly is happening.

from when.

KidkArolis avatar KidkArolis commented on May 18, 2024

One of the promises is getting resolved twice, I'll try to narrow it down.

from when.

briancavalier avatar briancavalier commented on May 18, 2024

Strange! Yeah, def let me know if you can track down the cause, or even get more info. Have you verified that your app works correctly with 1.5.0 in non-debug mode? There was a change to deferred.resolve/reject in 1.5.0. In non-debug mode they return silently now when you call them multiple times, whereas previously they threw. They will still throw in debug mode, tho (or at least they should!).

from when.

KidkArolis avatar KidkArolis commented on May 18, 2024

Yeah, then'ed callbacks are called twice now

var when = require("when");

var d = when.defer();

var count = 0;
when(d).then(function () {
  count += 1;
});

d.resolve();

count === 2;

from when.

briancavalier avatar briancavalier commented on May 18, 2024

Wow, ok, that's not good :) I verified that it's only in debug mode using your test ... normal mode seems to work correctly. Looks like I've got some work to do before 1.5.1 :)

from when.

briancavalier avatar briancavalier commented on May 18, 2024

Haha, it's a dumb mistake on my part in when/debug. I just pushed a fix for the double callbacks. Please try the dev branch again when you have a chance. If that's back to normal, I'll focus on slimming down the debug output.

from when.

KidkArolis avatar KidkArolis commented on May 18, 2024

Seems to be working better now.

And my output is not duplicated:

[object Promise 1.2.3.6] REJECTED: ReferenceError: iDontExist is not defined debug.js:110
[object Promise 1.2.3.5] REJECTED: ReferenceError: iDontExist is not defined debug.js:110
[object Promise 1.2.3.6.7] REJECTED: ReferenceError: iDontExist is not defined debug.js:110
(2 times) Uncaught ReferenceError: iDontExist is not defined 

I'll use this dev branch in my dev now and see how it goes.

from when.

briancavalier avatar briancavalier commented on May 18, 2024

Great. We'll probably go with what's in the dev branch now for 1.5.1. For 2.0, we will probably take a fresh look at debugging to see if there are other interesting approaches (it's all pretty brute force, right now). If you have ideas for what kind of information would be helpful while debugging promise code, I'd love to hear them!

If the original issue is fixed in dev, feel free to close this ticket, or wait until 1.5.1 is released to verify. Whichever you prefer.

from when.

briancavalier avatar briancavalier commented on May 18, 2024

Just released 1.5.1 so closing this as I believe the original issue is fixed. If not, please reopen!

from when.

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.