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

silverwind opened this Issue Jan 25, 2014 · 10 comments


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?


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.


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});

ctalkington commented Jan 25, 2014

would be part of the instance options.

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

ctalkington commented Jan 25, 2014

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


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


ctalkington commented Jan 25, 2014

either work, was just using the shorthand.


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.


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