next-bun-compile 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -175,6 +175,9 @@ class NodeResponseShim extends Writable {
175
175
  flush() {}
176
176
  // ---- body ----
177
177
  _write(chunk, encoding, callback) {
178
+ // Writes racing a client disconnect go nowhere on a real socket too —
179
+ // drop them quietly instead of erroring Next's render pipeline.
180
+ if (this.destroyed || this.req.aborted) return callback();
178
181
  this._implicitHeader();
179
182
  try {
180
183
  this._controller.enqueue(
@@ -195,8 +198,14 @@ class NodeResponseShim extends Writable {
195
198
  }
196
199
  _destroy(err, callback) {
197
200
  if (!this.finished) {
201
+ this.finished = true;
198
202
  try {
199
- this._controller.error(err ?? new Error("aborted"));
203
+ // A real error must propagate to the client's stream; but a plain
204
+ // teardown (client disconnect, bodyless cancel) closes it cleanly.
205
+ // error()-ing on abort surfaced every routine disconnect as an
206
+ // "unhandledRejection: Error: aborted" in Bun's response pump.
207
+ if (err) this._controller.error(err);
208
+ else this._controller.close();
200
209
  } catch {}
201
210
  }
202
211
  callback(err);
@@ -722,3 +731,6 @@ async function start(opts) {
722
731
  }
723
732
 
724
733
  module.exports = { start };
734
+ // Test-only escape hatch for unit-testing the fetch→node bridge. Not a public
735
+ // API — may change or disappear in any release without notice.
736
+ module.exports._internal = { createBridge, NodeResponseShim, makeNodeRequest };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-bun-compile",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Compile your Next.js app into a Bun single-file executable",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",