observablehq / framework

A static site generator for data apps, dashboards, reports, and more. Observable Framework combines JavaScript on the front-end for interactive graphics with any language on the back-end for data analysis.
https://observablehq.com/framework/
ISC License
2.41k stars 110 forks source link

Error after stopping the dev server when run in an npm workspace #1459

Closed nswanberg closed 3 months ago

nswanberg commented 3 months ago

It's a minor issue, but I see this error when stopping the Observable dev server when the Observable project is in an NPM workspace:

^Cnpm ERR! Lifecycle script `dev` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: undefined 
npm ERR!   at location: /Users/nate/belle/github/test-workspace/projects/another-framework 
# Create workspace directory
mkdir test-workspace
cd test-workspace

# Initialize npm workspace
echo '{
  "name": "test-workspace",
  "version": "1.0.0",
  "private": true,
  "workspaces": [
    "projects/*"
  ]
}' > package.json

# Create Observable project directory
mkdir -p projects/my-observable-project
cd projects

# Create an Observable project with defaults (the error also happens with an empty Observable project)
npm init @observablehq

# ... answer setup questions ...

cd ./hello-framework

# Run observable
npm run dev

# Hit CTRL-c to quit and see the error above
mbostock commented 3 months ago

I’m able to reproduce, and I’ve confirmed that this is caused by the signal handling added for telemetry:

https://github.com/observablehq/framework/blob/1b71e52094b3945803681ee208a1b0b07df25afb/src/telemetry.ts#L100-L102