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

Add setImmediate() #985

Closed
bantu opened this issue Nov 11, 2014 · 16 comments
Closed

Add setImmediate() #985

bantu opened this issue Nov 11, 2014 · 16 comments

Comments

@bantu
Copy link

bantu commented Nov 11, 2014

My browser complains about setImmediate() not being defined. This might be something for browserify to handle.

See https://github.com/andris9/smtp-connection/issues/9

@ibc
Copy link

ibc commented Nov 13, 2014

I do not understand, setImmediate() is defined within the Node timers module, so if you do this in your JS:

var timers = require('timers');

then you get the timers.setImmediate() definition within your browserified bundle.

@ibc
Copy link

ibc commented Nov 13, 2014

Tested, it just works.

@bantu
Copy link
Author

bantu commented Nov 13, 2014

@ibc
Copy link

ibc commented Nov 13, 2014

Report the issue in that project. setImmediate() is not a ECMA standard at all:

https://developer.mozilla.org/en-US/docs/Web/API/Window.setImmediate

Anyhow, why do you want to "browserify" smtp-connection? It is not a browser valid library given that it needs to open raw TCP connections (something unfeasible in a browser).

Please close this issue.

@bantu
Copy link
Author

bantu commented Nov 13, 2014

Anyhow, why do you want to "browserify" smtp-connection? It is not a browser valid library given that it needs to open raw TCP connections (something unfeasible in a browser).

In my project, I have functional node sockets in the browser. I want to send e-mail messages. It actually works already. Certainly not "infeasible".

@ibc
Copy link

ibc commented Nov 13, 2014

Sorry, I do not understand how do you have raw TCP sockets in the browser as that is imposible.

Anyhow, I've explained the issue, didn't I? why don't you comment about my rationale? OK, will repeat it:

Report the issue in that project. setImmediate() is not a ECMA standard at all (regardless it exists in Node as global function):

https://developer.mozilla.org/en-US/docs/Web/API/Window.setImmediate

@ibc
Copy link

ibc commented Nov 13, 2014

BTW you can solve your issue with this workaround:

global.setImmediate = require('timers').setImmediate;

require('smtpconnection');

Not tested.

@bantu
Copy link
Author

bantu commented Nov 13, 2014

Sorry, I do not understand how do you have raw TCP sockets in the browser as that is imposible.

I just use websockify and an adapter to Node.js sockets.

Report the issue in that project.

See https://github.com/andris9/smtp-connection/issues/9#issuecomment-62950838

setImmediate() is not a ECMA standard at all (regardless it exists in Node as global function)

It's called node-browserify, so this project is directly related to Node.js. And as such the project might opt to provide a replacement/workaround for the global Node.js setImmediate() function even though it is not part of the ECMA standard.

@bantu
Copy link
Author

bantu commented Nov 13, 2014

Maybe this should have been reported against https://github.com/substack/insert-module-globals which seems to handle these kind of things.

@ibc
Copy link

ibc commented Nov 13, 2014

@bantu
Copy link
Author

bantu commented Nov 13, 2014

For reference: http://nodejs.org/api/globals.html says "The timer functions are global variables. See the timers section."

@bantu
Copy link
Author

bantu commented Nov 13, 2014

@ibc Did not test your workaround. Mine looks as follows and seems to work. Thanks anyway.

...
// Inject global function setImmediate()
// See https://github.com/andris9/smtp-connection/issues/9
var insertGlobals = require('browserify/node_modules/insert-module-globals');
insertGlobals.vars.setImmediate = function () {
  return "require('timers').setImmediate";
};
var bundle = browserify({
  insertGlobals: insertGlobals
});
....

@ibc
Copy link

ibc commented Nov 13, 2014

Looks good :)

@bantu
Copy link
Author

bantu commented Nov 24, 2014

@substack Could you please explain why this was closed? Should this be reported against https://github.com/substack/insert-module-globals instead? Especially see #985 (comment)

@ghost
Copy link

ghost commented Nov 24, 2014

This falls more into the realm of javascript engines themselves since IE10 and 11 have setImmediate just like node.

@bantu
Copy link
Author

bantu commented Nov 24, 2014

All right, thanks.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants