Skip to content

Errors thrown in async setup are caught silently during SSR #15716

Description

@GrantGryczan

Vue version

3.5.43

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-kyxtdywv?file=main.js

Steps to reproduce

Open the reproduction link, which performs the following steps:

  1. Throws an error from a component's async setup.
  2. Renders the component using renderToString.

What is expected?

The error should propagate up to the renderToString call, causing it to return a rejected promise.

In the minimal reproduction, that rejection would be uncaught, so the error would appear in the Node.js console.

What is actually happening?

There's no uncaught error or unhandled promise rejection. The console only displays the following warnings:

[Vue warn]: Unhandled error during execution of setup function 
  at <App>
[Vue warn]: Component App is missing template or render function. 
  at <App>

Also, if there is a render function in the component throwing the error, it renders successfully as if no error occurred.

Any additional comments?

This bug is caused by 349eb0f#diff-96591cb7eb061552355cc70e508472b1acc2688c3449ad0daa19c3cbac08cc97R100, where onServerPrefetch was added. Originally, the bug only occurred when the setup synchronously calls onServerPrefetch.

That line intended to catch errors thrown from onServerPrefetch callbacks, but the .catch was mistakenly applied to the entire setup promise.

The bug was expanded to occur in all async setups in 6039e25#diff-96591cb7eb061552355cc70e508472b1acc2688c3449ad0daa19c3cbac08cc97R110 by no longer gating the .catch behind if (prefetches).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.scope: ssr

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions