Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Force the DNS module to invoke callbacks asynchronously #1164

Closed
dhruvbird opened this issue Jun 8, 2011 · 16 comments
Closed

Force the DNS module to invoke callbacks asynchronously #1164

dhruvbird opened this issue Jun 8, 2011 · 16 comments

Comments

@dhruvbird
Copy link

The current DNS module may call the callback function directly, which means that any code that assumes that the callback will be invoked only after the complete function executes is broken. Please could it be changed to invoke all callbacks (not just in the DNS module) by passing them to nextTick() if the calling function is the public API and it wants to invoke the user supplied callback.

@olalonde
Copy link

Could you write a code example?

@dhruvbird
Copy link
Author

@ry
Copy link

ry commented Jun 14, 2011

be careful. wont fix.

@ry ry closed this as completed Jun 14, 2011
@astro
Copy link

astro commented Jun 14, 2011

any reason why?

@ry
Copy link

ry commented Jul 8, 2011

i dont want to change API right now - also good for fast lookups.

@dhruvbird
Copy link
Author

But the change would only be noticeable to anyone who is relying on the callback to be invoked in the same tick right? And if anyone is relying on that, I guess it is bad practice anyways. What do you think?

@koichik
Copy link

koichik commented Jul 9, 2011

I think this fix does not change API because there is no guarantee that a callback is invoked immediately.

@dhruvbird
Copy link
Author

@koichik Like ;)

@ry ry reopened this Jul 26, 2011
@ry
Copy link

ry commented Jul 26, 2011

@koichik ok

@koichik
Copy link

koichik commented Jul 26, 2011

@ry Thanks!

@TooTallNate
Copy link

Frankly, I'm -1 to this because the API doesn't state that it will be invoked asynchronously either. The safe coder would prepare for the callback being invoked in either situation.

@koichik
Copy link

koichik commented Jul 27, 2011

the API doesn't state that it will be invoked asynchronously either.

Yes. It is the essence of the problem.
Please refer to HAVOC'S BLOG.

The safe coder would prepare for the callback being invoked in either situation.

I agree. So this fix does not impact to him/her.
However, this can save the careless coder like me :)

And, this also fixes #1202. I think that this helps many Noders.

@dhruvbird
Copy link
Author

Yes, agreed that people should not rely on either behaviour, but it's simple enough to ensure async callbacks.

@dhruvbird dhruvbird reopened this Jul 27, 2011
@koichik
Copy link

koichik commented Jul 27, 2011

Please review.

@dhruvbird
Copy link
Author

@ry, @bnoordhuis, @koichik Thanks!

@koichik
Copy link

koichik commented Aug 21, 2011

Please review 1aed45e.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants