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

Handle unhandledrejections in the dev server #9424

Merged
merged 6 commits into from
Dec 14, 2023
Merged

Conversation

matthewp
Copy link
Contributor

@matthewp matthewp commented Dec 13, 2023

Changes

  • Unhandled rejections, caused by having a promise that rejects but has no .catch(), will crash the dev server. We can prevent it using process.on('unhandledRejection').
Screen Shot 2023-12-13 at 9 35 02 AM
Screen Shot 2023-12-13 at 5 59 39 PM

Testing

  • Manually in demo project. See above screenshot. Server does not crash, good error message is displayed.

Docs

N/A, bug fix

Copy link

changeset-bot bot commented Dec 13, 2023

🦋 Changeset detected

Latest commit: 9b9f51b

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review labels Dec 13, 2023
@matthewp
Copy link
Contributor Author

!preview handle-unhandled

Copy link
Contributor

Snapshots have been released for the following packages:

  • @astrojs/lit@experimental--handle-unhandled
  • astro@experimental--handle-unhandled
  • @astrojs/vercel@experimental--handle-unhandled
Publish Log
🦋  warn ===============================IMPORTANT!===============================
🦋  warn Packages will be released under the experimental--handle-unhandled tag
🦋  warn ----------------------------------------------------------------------
🦋  info npm info astro
🦋  info npm info @astrojs/prism
🦋  info npm info @astrojs/rss
🦋  info npm info create-astro
🦋  info npm info @astrojs/alpinejs
🦋  info npm info @astrojs/lit
🦋  info npm info @astrojs/markdoc
🦋  info npm info @astrojs/mdx
🦋  info npm info @astrojs/node
🦋  info npm info @astrojs/partytown
🦋  info npm info @astrojs/preact
🦋  info npm info @astrojs/react
🦋  info npm info @astrojs/sitemap
🦋  info npm info @astrojs/solid-js
🦋  info npm info @astrojs/svelte
🦋  info npm info @astrojs/tailwind
🦋  info npm info @astrojs/vercel
🦋  info npm info @astrojs/vue
🦋  info npm info @astrojs/internal-helpers
🦋  info npm info @astrojs/markdown-remark
🦋  info npm info @astrojs/telemetry
🦋  info npm info @astrojs/underscore-redirects
🦋  info npm info @astrojs/upgrade
🦋  info astro is being published because our local version (0.0.0-handle-unhandled-20231213142946) has not been published on npm
🦋  warn @astrojs/prism is not being published because version 3.0.0 is already published on npm
🦋  warn @astrojs/rss is not being published because version 4.0.1 is already published on npm
🦋  warn create-astro is not being published because version 4.5.2 is already published on npm
🦋  warn @astrojs/alpinejs is not being published because version 0.3.1 is already published on npm
🦋  info @astrojs/lit is being published because our local version (0.0.0-handle-unhandled-20231213142946) has not been published on npm
🦋  warn @astrojs/markdoc is not being published because version 0.8.0 is already published on npm
🦋  warn @astrojs/mdx is not being published because version 2.0.1 is already published on npm
🦋  warn @astrojs/node is not being published because version 7.0.1 is already published on npm
🦋  warn @astrojs/partytown is not being published because version 2.0.2 is already published on npm
🦋  warn @astrojs/preact is not being published because version 3.0.1 is already published on npm
🦋  warn @astrojs/react is not being published because version 3.0.7 is already published on npm
🦋  warn @astrojs/sitemap is not being published because version 3.0.3 is already published on npm
🦋  warn @astrojs/solid-js is not being published because version 3.0.2 is already published on npm
🦋  warn @astrojs/svelte is not being published because version 5.0.1 is already published on npm
🦋  warn @astrojs/tailwind is not being published because version 5.0.3 is already published on npm
🦋  info @astrojs/vercel is being published because our local version (0.0.0-handle-unhandled-20231213142946) has not been published on npm
🦋  warn @astrojs/vue is not being published because version 4.0.3 is already published on npm
🦋  warn @astrojs/internal-helpers is not being published because version 0.2.1 is already published on npm
🦋  warn @astrojs/markdown-remark is not being published because version 4.0.1 is already published on npm
🦋  warn @astrojs/telemetry is not being published because version 3.0.4 is already published on npm
🦋  warn @astrojs/underscore-redirects is not being published because version 0.3.3 is already published on npm
🦋  warn @astrojs/upgrade is not being published because version 0.2.1 is already published on npm
🦋  info Publishing "astro" at "0.0.0-handle-unhandled-20231213142946"
🦋  info Publishing "@astrojs/lit" at "0.0.0-handle-unhandled-20231213142946"
🦋  info Publishing "@astrojs/vercel" at "0.0.0-handle-unhandled-20231213142946"
🦋  success packages published successfully:
🦋  astro@0.0.0-handle-unhandled-20231213142946
🦋  @astrojs/lit@0.0.0-handle-unhandled-20231213142946
🦋  @astrojs/vercel@0.0.0-handle-unhandled-20231213142946
🦋  Creating git tags...
🦋  New tag:  astro@0.0.0-handle-unhandled-20231213142946
🦋  New tag:  @astrojs/lit@0.0.0-handle-unhandled-20231213142946
🦋  New tag:  @astrojs/vercel@0.0.0-handle-unhandled-20231213142946
Build Log

> root@0.0.0 build /home/runner/work/astro/astro
> turbo run build --filter=astro --filter=create-astro --filter="@astrojs/*" --filter="@benchmark/*"

• Packages in scope: @astrojs/alpinejs, @astrojs/cloudflare, @astrojs/internal-helpers, @astrojs/lit, @astrojs/markdoc, @astrojs/markdown-remark, @astrojs/mdx, @astrojs/netlify, @astrojs/node, @astrojs/partytown, @astrojs/preact, @astrojs/prism, @astrojs/react, @astrojs/rss, @astrojs/sitemap, @astrojs/solid-js, @astrojs/svelte, @astrojs/tailwind, @astrojs/telemetry, @astrojs/underscore-redirects, @astrojs/upgrade, @astrojs/vercel, @astrojs/vue, @benchmark/timer, astro, create-astro
• Running build in 26 packages
• Remote caching enabled
::group::@astrojs/telemetry:build
cache hit, suppressing logs 20dce2800041ecab
::endgroup::
::group::@astrojs/internal-helpers:build
cache hit, suppressing logs eac91336501ec7d9
::endgroup::
::group::@astrojs/upgrade:build
cache hit, suppressing logs 2a93542d95491830
::endgroup::
::group::@astrojs/prism:build
cache hit, suppressing logs 81bed5c056d4b29d
::endgroup::
::group::create-astro:build
cache hit, suppressing logs a26580f945cb8884
::endgroup::
::group::@astrojs/markdown-remark:build
cache hit, suppressing logs 5ba3dfef4a1c58aa
::endgroup::
::group::astro:build
cache miss, executing a73753155a1b44cc

> astro@0.0.0-handle-unhandled-20231213142946 build /home/runner/work/astro/astro/packages/astro
> pnpm run prebuild && astro-scripts build "src/**/*.{ts,js}" && tsc && pnpm run postbuild


> astro@0.0.0-handle-unhandled-20231213142946 prebuild /home/runner/work/astro/astro/packages/astro
> astro-scripts prebuild --to-string "src/runtime/server/astro-island.ts" "src/runtime/client/{idle,load,media,only,visible}.ts"


> astro@0.0.0-handle-unhandled-20231213142946 postbuild /home/runner/work/astro/astro/packages/astro
> astro-scripts copy "src/**/*.astro" && astro-scripts copy "src/**/*.wasm"

::endgroup::
::group::@astrojs/lit:build
cache miss, executing c8df1d34aab47d31

> @astrojs/lit@0.0.0-handle-unhandled-20231213142946 build /home/runner/work/astro/astro/packages/integrations/lit
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/react:build
cache miss, executing 4ed68af7f26c893e

> @astrojs/react@3.0.7 build /home/runner/work/astro/astro/packages/integrations/react
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/underscore-redirects:build
cache miss, executing 6178084a368f5957

> @astrojs/underscore-redirects@0.3.3 build /home/runner/work/astro/astro/packages/underscore-redirects
> astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json

::endgroup::
::group::@benchmark/timer:build
cache miss, executing 96c2bf6308d8ca11

> @benchmark/timer@0.0.0 build /home/runner/work/astro/astro/benchmark/packages/timer
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/rss:build
cache miss, executing 4e0743af3b1d681f

> @astrojs/rss@4.0.1 build /home/runner/work/astro/astro/packages/astro-rss
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/node:build
cache miss, executing 8ee31cebcec50bef

> @astrojs/node@7.0.1 build /home/runner/work/astro/astro/packages/integrations/node
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/vercel:build
cache miss, executing e54f5d94bfe8ccee

> @astrojs/vercel@0.0.0-handle-unhandled-20231213142946 build /home/runner/work/astro/astro/packages/integrations/vercel
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/markdoc:build
cache miss, executing 3a9a461b236f092d

> @astrojs/markdoc@0.8.0 build /home/runner/work/astro/astro/packages/integrations/markdoc
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/svelte:build
cache miss, executing 292e189aa0b1d2f5

> @astrojs/svelte@5.0.1 build /home/runner/work/astro/astro/packages/integrations/svelte
> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc

::endgroup::
::group::@astrojs/vue:build
cache miss, executing 974f74086ef22a7c

> @astrojs/vue@4.0.3 build /home/runner/work/astro/astro/packages/integrations/vue
> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc

::endgroup::
::group::@astrojs/alpinejs:build
cache miss, executing a6d1f6f13947043c

> @astrojs/alpinejs@0.3.1 build /home/runner/work/astro/astro/packages/integrations/alpinejs
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/tailwind:build
cache miss, executing 6361d26269409457

> @astrojs/tailwind@5.0.3 build /home/runner/work/astro/astro/packages/integrations/tailwind
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/solid-js:build
cache miss, executing 4382a74ef5437483

> @astrojs/solid-js@3.0.2 build /home/runner/work/astro/astro/packages/integrations/solid
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/partytown:build
cache miss, executing 88ffa984a640cc1f

> @astrojs/partytown@2.0.2 build /home/runner/work/astro/astro/packages/integrations/partytown
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/preact:build
cache miss, executing 96634b57183f720d

> @astrojs/preact@3.0.1 build /home/runner/work/astro/astro/packages/integrations/preact
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/sitemap:build
cache miss, executing 09bd9a9e201920c7

> @astrojs/sitemap@3.0.3 build /home/runner/work/astro/astro/packages/integrations/sitemap
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/mdx:build
cache miss, executing 05a9556244f15bdf

> @astrojs/mdx@2.0.1 build /home/runner/work/astro/astro/packages/integrations/mdx
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::

 Tasks:    24 successful, 24 total
Cached:    6 cached, 24 total
  Time:    39.863s 

@matthewp matthewp marked this pull request as ready for review December 13, 2023 14:37
Comment on lines 47 to 53
function handleUnhandledRejection(rejection: any) {
const error = new AstroError({
...AstroErrorData.UnhandledRejection,
message: AstroErrorData.UnhandledRejection.message(rejection?.stack || rejection)
})
logger.error(null, error.message);
}
Copy link
Member

@Princesseuh Princesseuh Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit of a edge case, but presumably this should pass through our normal-ish error pipeline so we get a nicely formatted error.

export function formatErrorMessage(err: ErrorWithMetadata, showFullStacktrace: boolean): string {

How does this look in the browser too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can't pass through the normal error pipeline, it happens outside of the context of a request. You could do: setTimeout(() => Promise.reject('foo'), 5000) and there is no ongoing request, the rejection still happens.

It doesn't currently show up in the browser, do we have a way to send an error from the server to the client outside of a request?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think that from where you are in the code, you'd be able to send to the websocket since you're so close to the server creation, here's how it works in the rendering:

setTimeout(async () => loader.webSocketSend(await getViteErrorPayload(err)), 200)

You should just need to send the error payload through the websocket and it should work!»

It can't pass through the normal error pipeline, it happens outside of the context of a request.

If you can't make it go through the entire pipeline, at least formatting the error message would be great:

export function formatErrorMessage(err: ErrorWithMetadata, showFullStacktrace: boolean): string {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm looking to see if async_hooks can help. https://nodejs.org/api/async_hooks.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think AsyncLocalStorage can maybe allow this, going to give that try.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And so it begins... I have many ideas for AsyncLocalStorage!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the PR and it should work now. Updated with a screenshot of what the browser receives. Would appreciate another review @Princesseuh

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message looks good to me! 🥳

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
@matthewp matthewp marked this pull request as draft December 13, 2023 17:00
@matthewp
Copy link
Contributor Author

!preview handle-unhandled

Copy link
Contributor

Snapshots have been released for the following packages:

  • @astrojs/lit@experimental--handle-unhandled
  • astro@experimental--handle-unhandled
  • @astrojs/vercel@experimental--handle-unhandled
Publish Log
🦋  warn ===============================IMPORTANT!===============================
🦋  warn Packages will be released under the experimental--handle-unhandled tag
🦋  warn ----------------------------------------------------------------------
🦋  info npm info astro
🦋  info npm info @astrojs/prism
🦋  info npm info @astrojs/rss
🦋  info npm info create-astro
🦋  info npm info @astrojs/alpinejs
🦋  info npm info @astrojs/lit
🦋  info npm info @astrojs/markdoc
🦋  info npm info @astrojs/mdx
🦋  info npm info @astrojs/node
🦋  info npm info @astrojs/partytown
🦋  info npm info @astrojs/preact
🦋  info npm info @astrojs/react
🦋  info npm info @astrojs/sitemap
🦋  info npm info @astrojs/solid-js
🦋  info npm info @astrojs/svelte
🦋  info npm info @astrojs/tailwind
🦋  info npm info @astrojs/vercel
🦋  info npm info @astrojs/vue
🦋  info npm info @astrojs/internal-helpers
🦋  info npm info @astrojs/markdown-remark
🦋  info npm info @astrojs/telemetry
🦋  info npm info @astrojs/underscore-redirects
🦋  info npm info @astrojs/upgrade
🦋  info astro is being published because our local version (0.0.0-handle-unhandled-20231213202808) has not been published on npm
🦋  warn @astrojs/prism is not being published because version 3.0.0 is already published on npm
🦋  warn @astrojs/rss is not being published because version 4.0.1 is already published on npm
🦋  warn create-astro is not being published because version 4.5.2 is already published on npm
🦋  warn @astrojs/alpinejs is not being published because version 0.3.1 is already published on npm
🦋  info @astrojs/lit is being published because our local version (0.0.0-handle-unhandled-20231213202808) has not been published on npm
🦋  warn @astrojs/markdoc is not being published because version 0.8.0 is already published on npm
🦋  warn @astrojs/mdx is not being published because version 2.0.1 is already published on npm
🦋  warn @astrojs/node is not being published because version 7.0.1 is already published on npm
🦋  warn @astrojs/partytown is not being published because version 2.0.2 is already published on npm
🦋  warn @astrojs/preact is not being published because version 3.0.1 is already published on npm
🦋  warn @astrojs/react is not being published because version 3.0.7 is already published on npm
🦋  warn @astrojs/sitemap is not being published because version 3.0.3 is already published on npm
🦋  warn @astrojs/solid-js is not being published because version 3.0.2 is already published on npm
🦋  warn @astrojs/svelte is not being published because version 5.0.1 is already published on npm
🦋  warn @astrojs/tailwind is not being published because version 5.0.3 is already published on npm
🦋  info @astrojs/vercel is being published because our local version (0.0.0-handle-unhandled-20231213202808) has not been published on npm
🦋  warn @astrojs/vue is not being published because version 4.0.3 is already published on npm
🦋  warn @astrojs/internal-helpers is not being published because version 0.2.1 is already published on npm
🦋  warn @astrojs/markdown-remark is not being published because version 4.0.1 is already published on npm
🦋  warn @astrojs/telemetry is not being published because version 3.0.4 is already published on npm
🦋  warn @astrojs/underscore-redirects is not being published because version 0.3.3 is already published on npm
🦋  warn @astrojs/upgrade is not being published because version 0.2.1 is already published on npm
🦋  info Publishing "astro" at "0.0.0-handle-unhandled-20231213202808"
🦋  info Publishing "@astrojs/lit" at "0.0.0-handle-unhandled-20231213202808"
🦋  info Publishing "@astrojs/vercel" at "0.0.0-handle-unhandled-20231213202808"
🦋  success packages published successfully:
🦋  astro@0.0.0-handle-unhandled-20231213202808
🦋  @astrojs/lit@0.0.0-handle-unhandled-20231213202808
🦋  @astrojs/vercel@0.0.0-handle-unhandled-20231213202808
🦋  Creating git tags...
🦋  New tag:  astro@0.0.0-handle-unhandled-20231213202808
🦋  New tag:  @astrojs/lit@0.0.0-handle-unhandled-20231213202808
🦋  New tag:  @astrojs/vercel@0.0.0-handle-unhandled-20231213202808
Build Log

> root@0.0.0 build /home/runner/work/astro/astro
> turbo run build --filter=astro --filter=create-astro --filter="@astrojs/*" --filter="@benchmark/*"

• Packages in scope: @astrojs/alpinejs, @astrojs/cloudflare, @astrojs/internal-helpers, @astrojs/lit, @astrojs/markdoc, @astrojs/markdown-remark, @astrojs/mdx, @astrojs/netlify, @astrojs/node, @astrojs/partytown, @astrojs/preact, @astrojs/prism, @astrojs/react, @astrojs/rss, @astrojs/sitemap, @astrojs/solid-js, @astrojs/svelte, @astrojs/tailwind, @astrojs/telemetry, @astrojs/underscore-redirects, @astrojs/upgrade, @astrojs/vercel, @astrojs/vue, @benchmark/timer, astro, create-astro
• Running build in 26 packages
• Remote caching enabled
::group::@astrojs/telemetry:build
cache hit, suppressing logs 20dce2800041ecab
::endgroup::
::group::create-astro:build
cache hit, suppressing logs a26580f945cb8884
::endgroup::
::group::@astrojs/prism:build
cache hit, suppressing logs 81bed5c056d4b29d
::endgroup::
::group::@astrojs/internal-helpers:build
cache hit, suppressing logs eac91336501ec7d9
::endgroup::
::group::@astrojs/upgrade:build
cache hit, suppressing logs 2a93542d95491830
::endgroup::
::group::@astrojs/markdown-remark:build
cache hit, suppressing logs 5ba3dfef4a1c58aa
::endgroup::
::group::astro:build
cache miss, executing 201444a58fbc558e

> astro@0.0.0-handle-unhandled-20231213202808 build /home/runner/work/astro/astro/packages/astro
> pnpm run prebuild && astro-scripts build "src/**/*.{ts,js}" && tsc && pnpm run postbuild


> astro@0.0.0-handle-unhandled-20231213202808 prebuild /home/runner/work/astro/astro/packages/astro
> astro-scripts prebuild --to-string "src/runtime/server/astro-island.ts" "src/runtime/client/{idle,load,media,only,visible}.ts"


> astro@0.0.0-handle-unhandled-20231213202808 postbuild /home/runner/work/astro/astro/packages/astro
> astro-scripts copy "src/**/*.astro" && astro-scripts copy "src/**/*.wasm"

::endgroup::
::group::@astrojs/alpinejs:build
cache miss, executing 2c29212d069d7840

> @astrojs/alpinejs@0.3.1 build /home/runner/work/astro/astro/packages/integrations/alpinejs
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@benchmark/timer:build
cache miss, executing bf2c95c5bd9bbf7e

> @benchmark/timer@0.0.0 build /home/runner/work/astro/astro/benchmark/packages/timer
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/tailwind:build
cache miss, executing b9514647c331c5d3

> @astrojs/tailwind@5.0.3 build /home/runner/work/astro/astro/packages/integrations/tailwind
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/rss:build
cache miss, executing c263b6bcb606f327

> @astrojs/rss@4.0.1 build /home/runner/work/astro/astro/packages/astro-rss
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/underscore-redirects:build
cache miss, executing 52524ea8df5f8377

> @astrojs/underscore-redirects@0.3.3 build /home/runner/work/astro/astro/packages/underscore-redirects
> astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json

::endgroup::
::group::@astrojs/react:build
cache miss, executing 1dd4668aa6948ece

> @astrojs/react@3.0.7 build /home/runner/work/astro/astro/packages/integrations/react
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/preact:build
cache miss, executing 5d4a441f1463b996

> @astrojs/preact@3.0.1 build /home/runner/work/astro/astro/packages/integrations/preact
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/vercel:build
cache miss, executing 9f8fbbde9b159a2d

> @astrojs/vercel@0.0.0-handle-unhandled-20231213202808 build /home/runner/work/astro/astro/packages/integrations/vercel
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/vue:build
cache miss, executing dbadcc0cdc161146

> @astrojs/vue@4.0.3 build /home/runner/work/astro/astro/packages/integrations/vue
> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc

::endgroup::
::group::@astrojs/markdoc:build
cache miss, executing 73aa173990921263

> @astrojs/markdoc@0.8.0 build /home/runner/work/astro/astro/packages/integrations/markdoc
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/partytown:build
cache miss, executing ae12f90f90534f0e

> @astrojs/partytown@2.0.2 build /home/runner/work/astro/astro/packages/integrations/partytown
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/lit:build
cache miss, executing 506736be86ca0cc2

> @astrojs/lit@0.0.0-handle-unhandled-20231213202808 build /home/runner/work/astro/astro/packages/integrations/lit
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/node:build
cache miss, executing 1c006f90cc4a2b97

> @astrojs/node@7.0.1 build /home/runner/work/astro/astro/packages/integrations/node
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/solid-js:build
cache miss, executing e88668756c3a78ea

> @astrojs/solid-js@3.0.2 build /home/runner/work/astro/astro/packages/integrations/solid
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/svelte:build
cache miss, executing 36f35f301a0b2962

> @astrojs/svelte@5.0.1 build /home/runner/work/astro/astro/packages/integrations/svelte
> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc

::endgroup::
::group::@astrojs/mdx:build
cache miss, executing 215b3673b5ebe079

> @astrojs/mdx@2.0.1 build /home/runner/work/astro/astro/packages/integrations/mdx
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/sitemap:build
cache miss, executing 67e5a7443162a17c

> @astrojs/sitemap@3.0.3 build /home/runner/work/astro/astro/packages/integrations/sitemap
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::

 Tasks:    24 successful, 24 total
Cached:    6 cached, 24 total
  Time:    37.804s 

@matthewp matthewp marked this pull request as ready for review December 13, 2023 22:59
incomingRequest: request,
incomingResponse: response,
manifest,
localStorage.run(request, () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing in the request which acts as the context for the local storage. When an unhandled rejection occurs, we can use this to know which request it was associated with.

Copy link
Member

@ematipico ematipico Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First time I see AsyncLocalStorage in action!

const store = localStorage.getStore();
if(store instanceof IncomingMessage) {
const request = store;
setRouteError(controller.state, request.url!, error);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This marks the route as being in an error state.

Copy link
Member

@Princesseuh Princesseuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% satisfied with the stack trace in the error message, but since we don't show cause super well and it's a bit of a edge case, it's okay, we can improve it later if we get requests.

@matthewp matthewp merged commit e1a5a2d into main Dec 14, 2023
@matthewp matthewp deleted the unhandled-rejection branch December 14, 2023 13:39
@astrobot-houston astrobot-houston mentioned this pull request Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants