Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storybook: static server crashes every now and then #1280

Closed
florian-sanders-cc opened this issue Dec 11, 2024 · 0 comments · Fixed by #1287
Closed

Storybook: static server crashes every now and then #1280

florian-sanders-cc opened this issue Dec 11, 2024 · 0 comments · Fixed by #1287
Assignees
Labels
maintenance Code refactoring, project structure, dev tooling (storybook, dev server, npm tasks...)

Comments

@florian-sanders-cc
Copy link
Contributor

Context

For our prod storybook instance (https://www.clever-cloud.com/doc/clever-components/?path=/docs/readme--docs), we rely on node-static as a simple static Node.js server.

It seems that every now and then, the instance crashes and reboots with the following error:

2024-12-11T13:57:18.285Z node:_http_server:345
2024-12-11T13:57:18.285Z     throw new ERR_HTTP_HEADERS_SENT('write');
2024-12-11T13:57:18.285Z     ^
2024-12-11T13:57:18.285Z Error [ERR_HTTP_HEADERS_SENT]: Cannot write headers after they are sent to the client
2024-12-11T13:57:18.285Z     at ServerResponse.writeHead (node:_http_server:345:11)
2024-12-11T13:57:18.285Z     at Server.finish (/home/bas/app_91d78df5-c3dd-4c7f-b09a-8628e7e54860/node_modules/node-static/lib/node-static.js:125:17)
2024-12-11T13:57:18.285Z     at finish (/home/bas/app_91d78df5-c3dd-4c7f-b09a-8628e7e54860/node_modules/node-static/lib/node-static.js:170:14)
2024-12-11T13:57:18.285Z     at /home/bas/app_91d78df5-c3dd-4c7f-b09a-8628e7e54860/node_modules/node-static/lib/node-static.js:337:13
2024-12-11T13:57:18.285Z     at streamFile (/home/bas/app_91d78df5-c3dd-4c7f-b09a-8628e7e54860/node_modules/node-static/lib/node-static.js:382:13)
2024-12-11T13:57:18.285Z     at ReadStream.<anonymous> (/home/bas/app_91d78df5-c3dd-4c7f-b09a-8628e7e54860/node_modules/node-static/lib/node-static.js:375:17)
2024-12-11T13:57:18.285Z     at ReadStream.emit (node:events:519:28)
2024-12-11T13:57:18.285Z     at emitCloseNT (node:internal/streams/destroy:147:10)
2024-12-11T13:57:18.285Z     at process.processTicksAndRejections (node:internal/process/task_queues:81:21) {
2024-12-11T13:57:18.285Z   code: 'ERR_HTTP_HEADERS_SENT'
2024-12-11T13:57:18.285Z }

TLDR; the server tries to send a response but it has already sent one.

There is an open issue about this error on the node-static repo: cloudhead/node-static#241

I couldn't determine what types of requests triggered the error so I still need to dig a little bit but we may need to change the static server we use.
node-static hasn't been updated in 6 years, which is not necessarily an issue but even if it doesn't pull many dependencies, the ones it pulls are fairly outdated.

@florian-sanders-cc florian-sanders-cc added the maintenance Code refactoring, project structure, dev tooling (storybook, dev server, npm tasks...) label Dec 11, 2024
@florian-sanders-cc florian-sanders-cc self-assigned this Dec 11, 2024
florian-sanders-cc added a commit that referenced this issue Dec 19, 2024
- Remove the `node-static` dependency,
- Remove the `start` npm script,
- Add `.htaccess` to be used by the static Clever App (Apache server)

Fixes #1280
florian-sanders-cc added a commit that referenced this issue Dec 19, 2024
- Remove the `node-static` dependency,
- Remove the `start` npm script,
- Add `.htaccess` to be used by the static Clever App (Apache server)
  - The `.htaccess` file must be moved to `storybook-static` once the
    build is over.

Fixes #1280
florian-sanders-cc added a commit that referenced this issue Dec 19, 2024
- Remove the `node-static` dependency,
- Remove the `start` npm script,
- Add `.htaccess` to be used by the static Clever App (Apache server),
- Adapt the storybook build process to copy the `.htaccess` file to the
  `storybook-static` directory.

Fixes #1280
florian-sanders-cc added a commit that referenced this issue Dec 19, 2024
- Remove the `node-static` dependency,
- Remove the `start` npm script,
- Add `.htaccess` to be used by the static Clever App (Apache server),
- Adapt the storybook build process to copy the `.htaccess` file to the
  `storybook-static` directory.

Fixes #1280
florian-sanders-cc added a commit that referenced this issue Dec 19, 2024
- Remove the `node-static` dependency,
- Remove the `start` npm script,
- Add `.htaccess` to be used by the static Clever App (Apache server),
- Adapt the storybook build process to copy the `.htaccess` file to the
  `storybook-static` directory.

Fixes #1280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Code refactoring, project structure, dev tooling (storybook, dev server, npm tasks...)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant