ybogdanov / node-sync

Write simple and readable synchronous code in nodejs using fibers
MIT License
492 stars 70 forks source link

Does not work inside process:exit #17

Closed arcanis closed 12 years ago

arcanis commented 12 years ago

Hi,

Minimal showcase :

process.on('exit', function ( ) {
    require('sync')(function(){
        var source = require('fs').readFile.sync(null, __filename);
        console.log(String(source));
    });
} );
ybogdanov commented 12 years ago

'exit' is the last tick of event-loop. It's impossible to perform any asynchronous actions after 'exit' event was emitted. It's not a bug of node-sync - it's a nodejs feature ;)

process.on('exit', function ( ) {
    process.nextTick(function(){
        console.log('hehe'); // will never run
    });
});
arcanis commented 12 years ago

Yep, I have seen this in the doc, but I was hopping that it would work anyway with Sync.

Thanks :)