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

Type coercion problem in global setTimer #576

Closed
chefhoobajoob opened this issue Feb 12, 2022 · 1 comment
Closed

Type coercion problem in global setTimer #576

chefhoobajoob opened this issue Feb 12, 2022 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@chefhoobajoob
Copy link

Some js libraries making use of the setTimer function on es4x are sometimes generating exceptions with this message:

invokeMember (setTimer) on io.vertx.core.impl.VertxImpl@2c930868 failed due to: Cannot convert 'NaN'(language: Java, type: java.lang.Double) to Java type 'long': Invalid or lossy primitive coercion

Looks like there might be a type handling issue in the es4x implementation

@pmlopes pmlopes added the bug Something isn't working label Feb 14, 2022
@pmlopes pmlopes added this to the 0.17.1 milestone Feb 14, 2022
@pmlopes
Copy link
Contributor

pmlopes commented Feb 14, 2022

In the polyfill we're coercing the argument to number with Number(value) which can return NaN. We should either use the function isNaN() or do an extra verification against x !== x

See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN

Do not confuse with Number.isNaN()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants