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

[🐞] V2 - Promises not expected here #7000

Closed
ianlet opened this issue Oct 26, 2024 · 1 comment · Fixed by #7001
Closed

[🐞] V2 - Promises not expected here #7000

ianlet opened this issue Oct 26, 2024 · 1 comment · Fixed by #7001
Assignees

Comments

@ianlet
Copy link
Contributor

ianlet commented Oct 26, 2024

Which component is affected?

Qwik Runtime

Describe the bug

Introduced in Qwik V2, the error Promises not expected here. is thrown when rendering a component with a conditional projection that is async.

For example:

// File: src/routes/index.tsx

export default component$(() => {
  const open = useSignal(false);

  return (
    <TheCursedReveal open={open.value}>
      {t("I am an async string")}
    </TheCursedReveal>
  );
});

const TheCursedReveal = component$<{
  open: boolean;
}>(({ open }) => {
  return <>{open && <Slot />}</>;
});

async function t(key: string): Promise<string> {
  return Promise.resolve(key);
}

Any other variants of a <Slot /> being conditionally rendered will give the same error. For example:

const TheOtherCursedReveal = component$<{
  open: boolean;
}>(({ open }) => {
  if (!open) return null;

  return (
    <div>
      <Slot />
    </div>
  );
});

Additionally, the error is so obscure that it doesn't help at all to understand where and why this error is triggered:

QWIK ERROR Promises not expected here. Error: Promises not expected here.
    at createAndLogError (/home/ian/Projects/noma/node_modules/.pnpm/@builder.io+qwik@file+..+oss+qwik+packages+qwik_prettier@3.3.3_vite@5.4.9_@types+node@22.7.7__3o4nugbb2q2oqnvka6jhcm2faq/node_modules/@builder.io/qwik/dist/core.mjs:53:52)
    at throwErrorAndStop (/home/ian/Projects/noma/node_modules/.pnpm/@builder.io+qwik@file+..+oss+qwik+packages+qwik_prettier@3.3.3_vite@5.4.9_@types+node@22.7.7__3o4nugbb2q2oqnvka6jhcm2faq/node_modules/@builder.io/qwik/dist/core.mjs:28:17)
    at drain (/home/ian/Projects/noma/node_modules/.pnpm/@builder.io+qwik@file+..+oss+qwik+packages+qwik_prettier@3.3.3_vite@5.4.9_@types+node@22.7.7__3o4nugbb2q2oqnvka6jhcm2faq/node_modules/@builder.io/qwik/dist/core.mjs:3202:20)
    at Module._walkJSX (/home/ian/Projects/noma/node_modules/.pnpm/@builder.io+qwik@file+..+oss+qwik+packages+qwik_prettier@3.3.3_vite@5.4.9_@types+node@22.7.7__3o4nugbb2q2oqnvka6jhcm2faq/node_modules/@builder.io/qwik/dist/core.mjs:3226:3)
    at SSRContainer.emitUnclaimedProjection (/home/ian/Projects/noma/node_modules/.pnpm/@builder.io+qwik@file+..+oss+qwik+packages+qwik_prettier@3.3.3_vite@5.4.9_@types+node@22.7.7__3o4nugbb2q2oqnvka6jhcm2faq/node_modules/@builder.io/qwik/dist/server.mjs:8721:35)
    at SSRContainer.emitContainerData (/home/ian/Projects/noma/node_modules/.pnpm/@builder.io+qwik@file+..+oss+qwik+packages+qwik_prettier@3.3.3_vite@5.4.9_@types+node@22.7.7__3o4nugbb2q2oqnvka6jhcm2faq/node_modules/@builder.io/qwik/dist/server.mjs:8414:10)
    at SSRContainer.closeElement (/home/ian/Projects/noma/node_modules/.pnpm/@builder.io+qwik@file+..+oss+qwik+packages+qwik_prettier@3.3.3_vite@5.4.9_@types+node@22.7.7__3o4nugbb2q2oqnvka6jhcm2faq/node_modules/@builder.io/qwik/dist/server.mjs:8239:24)
    at drain (/home/ian/Projects/noma/node_modules/.pnpm/@builder.io+qwik@file+..+oss+qwik+packages+qwik_prettier@3.3.3_vite@5.4.9_@types+node@22.7.7__3o4nugbb2q2oqnvka6jhcm2faq/node_modules/@builder.io/qwik/dist/core.mjs:3207:31)
    at resolveValue (/home/ian/Projects/noma/node_modules/.pnpm/@builder.io+qwik@file+..+oss+qwik+packages+qwik_prettier@3.3.3_vite@5.4.9_@types+node@22.7.7__3o4nugbb2q2oqnvka6jhcm2faq/node_modules/@builder.io/qwik/dist/core.mjs:3189:5)
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

Additional Information

Debugging:

@ianlet ianlet added STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working labels Oct 26, 2024
@Varixo Varixo self-assigned this Oct 26, 2024
@Varixo Varixo linked a pull request Oct 26, 2024 that will close this issue
@Varixo
Copy link
Member

Varixo commented Oct 27, 2024

Nice catch! Thank you for the reproduction 😄 Should be fixed now

@Varixo Varixo closed this as completed Oct 27, 2024
@Varixo Varixo added COMP: runtime VERSION: upcoming major and removed STATUS-1: needs triage New issue which needs to be triaged labels Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants