Avoiding "process exited before Archiver could finish emitting data" #59

Closed
silverwind opened this Issue Jan 25, 2014 · 10 comments

Comments

Projects
None yet
2 participants

Hey, I'm using archiver to stream zips over http and when the server gets shut down while there's still a transfer in progress, I get this seemingly uncatchable error thrown.

Right now, I'm setting

archive.catchEarlyExitAttached = true;

to avoid getting the handler attached, but this seems pretty hackish. Would an option to control this behavior be reasonable?

Owner

ctalkington commented Jan 25, 2014

does the http throw any event when this happens? (havent done anything like this myself).

I haven't found any helpful events so far. The problem is, I'm forcefully shutting down the process via SIGINT (CTRL-C) in my case, which pretty interrupts everything and triggers your process.once('exit').

I could probably code a graceful shutdown on SIGINT, but I still think there are cases where you want to stop everything immediatly.

Owner

ctalkington commented Jan 25, 2014

published 0.5.2 with catchEarly option that you'll want to set to false. this is an experimental option at this point in time and could be adjusted/removed down the road. (ie why I didnt bump to 0.6.0 or document the option in README.)

Thanks! Now I'm just wondering on how to set this option. Am I completely wrong with something like this (It complains about an unknown format)?

require("archiver")(null, {catchEarly: false});
Owner

ctalkington commented Jan 25, 2014

would be part of the instance options.

var archiver = require('archiver');
var instance = archiver('zip', { catchEarly: false });
Owner

ctalkington commented Jan 25, 2014

using one of your projects as example, it should go here:

https://github.com/silverwind/droppy/blob/master/droppy.js#L1137

Ah, of course, I've been doing the instancing wrong the whole time with just archiver.create() instead of archiver(). It's working now, thanks!

Here's the change: silverwind/droppy@fbe7f25

Owner

ctalkington commented Jan 25, 2014

either work, was just using the shorthand.

Owner

ctalkington commented Jan 25, 2014

also, something i noticed. your using finalize callback to end the response, this is bad practice and finalize will end the archive stream (eventually) which will call end on the response by default.

https://gist.github.com/ctalkington/75fe3fd75ef835af75e4

Interesting, I'll check it out later. I still have a lot to learn when it comes to streams :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment