poveste 0.8.2 → 0.9.0

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.
package/dist/node/bin.js CHANGED
@@ -13,17 +13,21 @@ process.env.POVESTE = 'true';
13
13
  // and take it away, which Vike does — and a failed build then ran forever with
14
14
  // its error already printed (#405).
15
15
  //
16
- // So failure is reported and exited here, deliberately. `exitCode` alone is not
17
- // enough — teardown does not get every handle back, and after a failed build a
18
- // `Timeout` and three `MessagePort`s are still open, so waiting for an empty
19
- // event loop is what hung in the first place. But exiting on the same tick as
20
- // the error would truncate it: writes to a piped stderr are asynchronous, and a
21
- // framed compiler error is long.
16
+ // So failure is reported here, the exit code set, and the process forced out if
17
+ // it does not leave on its own. Closing the collection ports (#426) was not
18
+ // enough on its own: a failed build still hangs in the nuxt4 and sveltekit books,
19
+ // holding `FSEventWrap` and `FSReqCallback` handles — watchers nothing closes on
20
+ // the error path. And `dev` and `preview` hold a listening server by design, so
21
+ // for them no amount of leak-fixing would ever let the loop drain.
22
22
  //
23
- // So both: the exit code is set immediately, and the hard exit is a timer that
24
- // does not itself hold the loop open. A process with nothing leaked exits on its
25
- // own, flushing normally; one that leaked is cut loose a moment later, by which
26
- // time the error has been written.
23
+ // The timer is unref'd, so it never fires for a process that ends by itself and
24
+ // costs nothing when there is nothing to force. It is 500ms rather than
25
+ // immediate because exiting on the same tick as `console.error` truncates it:
26
+ // writes to a piped stderr are asynchronous, and a framed compiler error is long.
27
+ //
28
+ // It does mean a leak reads as a clean failure from the outside, so it hides the
29
+ // class of bug #426 was. Removing it again needs those watcher handles closed
30
+ // first, and a guard that measures the resource list rather than the exit code.
27
31
  function run(command) {
28
32
  return command().then(() => undefined, (error) => {
29
33
  console.error(error);
@@ -79,18 +79,23 @@ export function useCollectStories(options, ctx) {
79
79
  });
80
80
  }
81
81
  async function executeStoryFile(storyFile) {
82
+ // The channel belongs to this execution, and nothing used to close it. On a
83
+ // build that fails, the executions still in flight are abandoned mid-run and
84
+ // their main-thread ports stay open and listening — enough live handles to
85
+ // keep the process alive with nothing left to do (#426).
86
+ let channel;
82
87
  try {
83
- const { workerPort } = createChannel();
88
+ channel = createChannel();
84
89
  const payload = {
85
90
  root: server.config.root,
86
91
  base: server.config.base,
87
92
  storyFile,
88
- port: workerPort,
93
+ port: channel.workerPort,
89
94
  defineGlobals,
90
95
  };
91
96
  const { storyData } = await threadPool.run(payload, {
92
97
  transferList: [
93
- workerPort,
98
+ channel.workerPort,
94
99
  ],
95
100
  });
96
101
  if (storyData.length === 0) {
@@ -125,6 +130,9 @@ export function useCollectStories(options, ctx) {
125
130
  throw e;
126
131
  }
127
132
  }
133
+ finally {
134
+ channel?.port.close();
135
+ }
128
136
  }
129
137
  async function destroy() {
130
138
  await threadPool.destroy();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "poveste",
3
3
  "type": "module",
4
- "version": "0.8.2",
4
+ "version": "0.9.0",
5
5
  "description": "Interactive component playgrounds for Vue, Svelte and Nuxt — a maintained, drop-in successor to histoire",
6
6
  "author": {
7
7
  "name": "Sorin Gitlan"
@@ -98,10 +98,10 @@
98
98
  "sirv": "^3.0.0",
99
99
  "unhead": "^3.1.0",
100
100
  "vite-node": "^6.0.0",
101
- "@poveste/app": "^0.8.2",
102
- "@poveste/controls": "^0.8.2",
103
- "@poveste/shared": "^0.8.2",
104
- "@poveste/vendors": "^0.8.2"
101
+ "@poveste/app": "^0.9.0",
102
+ "@poveste/controls": "^0.9.0",
103
+ "@poveste/shared": "^0.9.0",
104
+ "@poveste/vendors": "^0.9.0"
105
105
  },
106
106
  "devDependencies": {
107
107
  "@types/fs-extra": "^11.0.4",