clearTimeout breaks for null timer

541 views
Skip to first unread message

Jacob Rus

unread,
Aug 12, 2009, 12:12:18 PM8/12/09
to NodeJS list
Hi everyone,

In every browser (as far as I know), `clearTimeout(null)` does
nothing, but in node, it raises an exception. For the sake of
interoperability, it strikes me that it should behave as in browsers.
(And the browser behavior seems logical; defensively clearing timeouts
which may or may not exist doesn't really hurt anything.)

[If it's useful, I can send a patch for fixing this, but I imagine you
can do the fix as quickly.]

Cheers,
Jacob Rus

Tim Caswell

unread,
Aug 12, 2009, 12:17:34 PM8/12/09
to nod...@googlegroups.com
Just for clarification, I think you mean undefined and not null For
example always clearing a timeout right before setting it. The first
time the variable's value will be undefined. The only case I can
think of where it's null is where you explicitly define your variable
to null first.

Jacob Rus

unread,
Aug 12, 2009, 12:21:56 PM8/12/09
to nod...@googlegroups.com
Tim Caswell wrote:

> Jacob Rus wrote:
>> In every browser (as far as I know), `clearTimeout(null)` does
>> nothing, but in node, it raises an exception. [...]

>
> Just for clarification, I think you mean undefined and not null For
> example always clearing a timeout right before setting it.  The first
> time the variable's value will be undefined.  The only case I can
> think of where it's null is where you explicitly define your variable
> to null first.

Well, I think it should work for both (or really, just work however
the browser works; I haven't tested what that is for strings, etc.).
Because yes, I currently explicitly set my variables to null.

Cheers,
Jacob

ryan dahl

unread,
Aug 13, 2009, 5:41:05 AM8/13/09
to nod...@googlegroups.com
> [If it's useful, I can send a patch for fixing this, but I imagine you
> can do the fix as quickly.]

Okay - I'll accept a patch

Hint: http://github.com/ry/node/blob/4253baf4ab02c9700a9fe9e5440a9de35149e908/src/node.js#L36-39

Reply all
Reply to author
Forward
0 new messages