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

ActionError and Node Adapter #12489

Open
1 task done
abegehr opened this issue Nov 21, 2024 · 1 comment
Open
1 task done

ActionError and Node Adapter #12489

abegehr opened this issue Nov 21, 2024 · 1 comment
Labels
feat: actions Related to Astro actions (scope) pkg: node Related to Node adapter (scope)

Comments

@abegehr
Copy link

abegehr commented Nov 21, 2024

Astro Info

Astro                    v4.15.9
Node                     v22.6.0
System                   macOS (arm64)
Package Manager          unknown
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

I've tested on Safari and Chrome and occurs on both.

Describe the Bug

  1. Create an action that throws an ActionError: https://docs.astro.build/en/guides/actions/#creating-an-actionerror
  2. Call the action from a form: https://docs.astro.build/en/guides/actions/#call-actions-from-an-html-form-action
  3. Use the node adapter to host the astro app, build it, and start the server.
  4. Submit the form to run the action.
  5. Issue: The page is blank with status code of the ActionError. When run in dev mode, the error can be shown using Astro.getActionResult(): https://docs.astro.build/en/guides/actions/#handle-form-action-errors

What's the expected result?

I would expect the node adapter to handle action error the same as the dev mode.

To repro the issue, build and preview: npm run build and npm run preview to host astro on the standalone node adapter. The issue also occurs on the node middleware adapter, which is what I'm using.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-iad8ez

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Nov 21, 2024
@abegehr
Copy link
Author

abegehr commented Nov 21, 2024

Running with npm run dev works fine:

Screenshot 2024-11-21 at 10 11 24

Running dist with npm run preview fails:

Screenshot 2024-11-21 at 10 12 02

Console:

anton@Mac github-iad8ez % npm run dev    

> @example/[email protected] dev
> astro dev

10:10:53 [types] Generated 1ms

 astro  v4.16.13 ready in 91 ms

┃ Local    http://localhost:4321/
┃ Network  use --host to expose

10:10:53 watching for file changes...
10:10:55 [500] / 38ms
myAction() test1
10:10:57 [302] POST / 15ms
10:10:57 [500] / 3ms
^C
anton@Mac github-iad8ez % npm run preview

> @example/[email protected] preview
> astro preview

10:11:43 [@astrojs/node] Server listening on http://localhost:4321
myAction() test2

@ascorbic ascorbic added feat: actions Related to Astro actions (scope) pkg: node Related to Node adapter (scope) and removed needs triage Issue needs to be triaged labels Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: actions Related to Astro actions (scope) pkg: node Related to Node adapter (scope)
Projects
None yet
Development

No branches or pull requests

2 participants