houdini 2.0.4 → 2.0.5

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/build/cmd/init.js CHANGED
@@ -472,12 +472,12 @@ async function packageJSON(targetPath, frameworkInfo) {
472
472
  }
473
473
  packageJSON2.devDependencies = {
474
474
  ...packageJSON2.devDependencies,
475
- houdini: "^2.0.4"
475
+ houdini: "^2.0.5"
476
476
  };
477
477
  if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
478
478
  packageJSON2.devDependencies = {
479
479
  ...packageJSON2.devDependencies,
480
- "houdini-svelte": "^3.0.1"
480
+ "houdini-svelte": "^3.0.2"
481
481
  };
482
482
  } else {
483
483
  throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
@@ -302,49 +302,72 @@ async function codegen_setup(config, mode, db, db_file) {
302
302
  });
303
303
  _db.run("DELETE FROM plugins");
304
304
  _db.flush();
305
- logger.time("Start Plugins");
306
- await Promise.all(
307
- config.plugins.map(async (plugin) => {
308
- let executable = plugin.executable;
309
- const args = ["--database", db_file];
310
- const jsExtensions = [".js", ".mjs", ".cjs"];
311
- if (jsExtensions.includes(path.extname(plugin.executable))) {
312
- executable = "node";
313
- args.unshift(plugin.executable);
314
- } else if (path.extname(plugin.executable) === ".wasm") {
315
- executable = "node";
316
- args.unshift(wasiRunnerPath, plugin.executable);
317
- }
318
- const dbKey = plugin_db_key(plugin.name);
319
- args.push("--plugin-key", dbKey);
320
- const pluginUsesStdio = useStdio || path.extname(plugin.executable) === ".wasm";
321
- if (pluginUsesStdio) {
322
- args.push("--transport", "stdio");
305
+ const spawnedChildren = [];
306
+ const kill_spawned = () => {
307
+ for (const { child, detached } of spawnedChildren) {
308
+ if (child.pid === void 0 || child.exitCode !== null) continue;
309
+ try {
310
+ if (process.platform === "win32") {
311
+ child.kill();
312
+ } else {
313
+ process.kill(detached ? -child.pid : child.pid, "SIGINT");
314
+ }
315
+ } catch {
323
316
  }
324
- logger.time(`Spawn ${plugin.name}`);
325
- const child = spawn(executable, args, {
326
- // stdio/WASM plugins carry the protocol over stdin+stdout, so those must be pipes.
327
- // websocket plugins talk over TCP, so let stdout/stderr through to the console.
328
- stdio: pluginUsesStdio ? ["pipe", "pipe", "inherit"] : ["inherit", "inherit", "inherit"],
329
- // stdio plugins can't be detached: WebContainers doesn't plumb the pipe
330
- // to a detached child's fd 0, so the plugin gets EBADF reading stdin.
331
- // They're torn down by closing stdin, so they don't need a process group.
332
- detached: process.platform !== "win32" && !pluginUsesStdio
333
- });
334
- if (pluginUsesStdio) {
335
- stdioStdin.set(dbKey, child.stdin);
336
- child.stdin.on("error", (err) => {
337
- if (err.code !== "EPIPE") {
338
- console.error(`[${plugin.name}] stdin error:`, err.message);
339
- }
317
+ }
318
+ };
319
+ const guarded = async (fn) => {
320
+ try {
321
+ return await fn();
322
+ } catch (err) {
323
+ kill_spawned();
324
+ throw err;
325
+ }
326
+ };
327
+ logger.time("Start Plugins");
328
+ await guarded(
329
+ () => Promise.all(
330
+ config.plugins.map(async (plugin) => {
331
+ let executable = plugin.executable;
332
+ const args = ["--database", db_file];
333
+ const jsExtensions = [".js", ".mjs", ".cjs"];
334
+ if (jsExtensions.includes(path.extname(plugin.executable))) {
335
+ executable = "node";
336
+ args.unshift(plugin.executable);
337
+ } else if (path.extname(plugin.executable) === ".wasm") {
338
+ executable = "node";
339
+ args.unshift(wasiRunnerPath, plugin.executable);
340
+ }
341
+ const dbKey = plugin_db_key(plugin.name);
342
+ args.push("--plugin-key", dbKey);
343
+ const pluginUsesStdio = useStdio || path.extname(plugin.executable) === ".wasm";
344
+ if (pluginUsesStdio) {
345
+ args.push("--transport", "stdio");
346
+ }
347
+ logger.time(`Spawn ${plugin.name}`);
348
+ const detached = process.platform !== "win32" && !pluginUsesStdio;
349
+ const child = spawn(executable, args, {
350
+ // stdio/WASM plugins carry the protocol over stdin+stdout, so those must be pipes.
351
+ // websocket plugins talk over TCP, so let stdout/stderr through to the console.
352
+ stdio: pluginUsesStdio ? ["pipe", "pipe", "inherit"] : ["inherit", "inherit", "inherit"],
353
+ detached
340
354
  });
341
- }
342
- plugins[plugin.name] = {
343
- process: child,
344
- ...await (pluginUsesStdio ? wait_for_plugin_stdio(plugin.name, child) : wait_for_plugin_db(plugin.name, dbKey))
345
- };
346
- logger.timeEnd(`Spawn ${plugin.name}`, LogLevel.Verbose);
347
- })
355
+ spawnedChildren.push({ child, detached });
356
+ if (pluginUsesStdio) {
357
+ stdioStdin.set(dbKey, child.stdin);
358
+ child.stdin.on("error", (err) => {
359
+ if (err.code !== "EPIPE") {
360
+ console.error(`[${plugin.name}] stdin error:`, err.message);
361
+ }
362
+ });
363
+ }
364
+ plugins[plugin.name] = {
365
+ process: child,
366
+ ...await (pluginUsesStdio ? wait_for_plugin_stdio(plugin.name, child) : wait_for_plugin_db(plugin.name, dbKey))
367
+ };
368
+ logger.timeEnd(`Spawn ${plugin.name}`, LogLevel.Verbose);
369
+ })
370
+ )
348
371
  );
349
372
  for (const plugin of config.plugins) {
350
373
  plugin_specs.push(spec_results[plugin.name]);
@@ -484,11 +507,13 @@ async function codegen_setup(config, mode, db, db_file) {
484
507
  return result;
485
508
  };
486
509
  triggerHookRef.fn = trigger_hook;
487
- await write_config(_db, config, invoke_hook, plugin_specs, mode, logger);
488
- _db.flush();
489
- await trigger_hook("Config");
490
- await trigger_hook("AfterLoad");
491
- await trigger_hook("Schema");
510
+ await guarded(async () => {
511
+ await write_config(_db, config, invoke_hook, plugin_specs, mode, logger);
512
+ _db.flush();
513
+ await trigger_hook("Config");
514
+ await trigger_hook("AfterLoad");
515
+ await trigger_hook("Schema");
516
+ });
492
517
  let pipelineQueue = Promise.resolve();
493
518
  return {
494
519
  database_path: db_file,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",
@@ -52,7 +52,7 @@
52
52
  "recast": "^0.23.11",
53
53
  "sql.js": "^1.14.1",
54
54
  "ws": "^8.21.0",
55
- "houdini-core": "^2.0.3"
55
+ "houdini-core": "^2.0.4"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "graphql": ">=16",