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

Zero handleId returned by setImmediate() #3572

Closed
gkalpak opened this issue Apr 15, 2018 · 2 comments
Closed

Zero handleId returned by setImmediate() #3572

gkalpak opened this issue Apr 15, 2018 · 2 comments
Assignees

Comments

@gkalpak
Copy link
Contributor

gkalpak commented Apr 15, 2018

RxJS version:
6.0.0-uncanny-rc.7 (probably present since 6.0.0-alpha.1

Code to reproduce:
We ran into it by using an internal property:

import {asapScheduler} from 'rxjs';
...
if (asapScheduler.scheduled) {
  // Not reaching this line if `scheduled === 0`.
}

Additional information:
The internal implementation of setImmediate() returns a zero handleId the first time it is called. Although there is no official spec for setImmediate(), one would expect that the returned value would be similar to those of setTimeout() and setInterval(), which are both non-zero positive integers.

Furthermore, the return value is used by AsapScheduler's AsapAction, which checks it for truthy-ness and "re-schedules" with setImmediate() if it is falsy (e.g. 0).

This seems to have been broken in 5eb6af7.

I am not sure if this can actually break something.
We were bitten by it in angular.io, because we were using the internal scheduled property (which is assigned the handleId returned by setImmediate()) and checking it for truthy-ness. It is easy for us to work-around, but bringing it up in case it might actually break something (by calling setImmediate() more then once).

@benlesh
Copy link
Member

benlesh commented Apr 26, 2018

It seems like there's two things that need to happen here:

  1. We can make the setImmediate (which is an abandoned API now, AFAIK), return an id starting at 1.
  2. We need to deprecate these properties as no one should be using them.

@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants