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

[🐞] Issue with qwik deepfreezing objects when chaining server$ calls #7254

Open
brunsten opened this issue Jan 14, 2025 · 1 comment
Open
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working

Comments

@brunsten
Copy link

brunsten commented Jan 14, 2025

Which component is affected?

Qwik Runtime

Describe the bug

Passing an object through a chain of server$ calls will make the object frozen giving an error:
Error: 'getOwnPropertyDescriptor' on proxy: trap returned descriptor for property 'XXX' that is incompatible with the existing property in the proxy target

Reproduction

Steps to reproduce

you can use this "standalone" component on qwik 1.12.0 to get the error displayed

import { component$, Resource, useResource$, useStore } from "@builder.io/qwik";

import { server$ } from "@builder.io/qwik-city";

const printHello = server$(async (hello: Hello) => {
  // Returning immediately here will work, i.e:
  // return hello.print + " world";
  // But if we returning another server$ function, will cause an error:
  // Error: 'getOwnPropertyDescriptor' on proxy: trap returned descriptor for property 'print' that is incompatible with the existing property in the proxy target
  return await printHello2(hello);
});

const printHello2 = server$(async (hello: Hello) => hello.print + " world2");

export interface Hello {
  print: string;
}

export default component$(() => {
  const helloStore = useStore<Hello>({ print: "hello" });
  const resource = useResource$(async () => {
    return await printHello(helloStore);
    // Instead of using helloStore, we can do this to workaround it:
    // return await printHello({
    //   print: helloStore.print
    // });
  });
  return (
    <>
      <Resource
        value={resource}
        onPending={() => <div>Loading...</div>}
        onRejected={(error) => <div>Error: {error.message}</div>}
        onResolved={(data) => <div>Data: {data}</div>}
      />
    </>
  );
});

System Info

System:
    OS: macOS 14.1.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 81.73 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    Yarn: 1.22.22 - ~/node_modules/.bin/yarn
    npm: 10.9.2 - ~/node_modules/.bin/npm
    pnpm: 8.11.0 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 131.0.6778.265
    Safari: 17.1
  npmPackages:
    @builder.io/qwik: ^1.12.0 => 1.12.0 
    @builder.io/qwik-city: ^1.12.0 => 1.12.0 
    typescript: 5.4.5 => 5.4.5 
    undici: * => 6.21.0 
    vite: 5.3.5 => 5.3.5

Additional Information

Stack trace:

at Function.isFrozen (<anonymous>)
 at ./node_modules/@builder.io/qwik-city/lib/index.qwik.mjs:1521:55
 at Array.forEach (<anonymous>)
 at deepFreeze (./node_modules/@builder.io/qwik-city/lib/index.qwik.mjs:1519:35)
 at serverQrl_rpc_FusI6N08iPY (./node_modules/@builder.io/qwik-city/lib/index.qwik.mjs:1551:48)
 at ./node_modules/dist-dev/tsc-out/packages/qwik/dist-dev/tsc-out/packages/qwik/src/core/qrl/qrl-class.js:55:31
 at invokeApply (./node_modules/dist-dev/tsc-out/packages/qwik/dist-dev/tsc-out/packages/qwik/src/core/use/use-core.js:66:26)
 at invoke (./node_modules/dist-dev/tsc-out/packages/qwik/dist-dev/tsc-out/packages/qwik/src/core/use/use-core.js:58:24)
 at ./node_modules/dist-dev/tsc-out/packages/qwik/dist-dev/tsc-out/packages/qwik/src/core/qrl/qrl-class.js:117:27
 at maybeThen (./node_modules/dist-dev/tsc-out/packages/qwik/dist-dev/tsc-out/packages/qwik/src/core/util/promises.js:20
@brunsten brunsten added STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working labels Jan 14, 2025
@damianpumar
Copy link
Contributor

Hello @brunsten
Thanks for report this issue, I will be working to fix it!

Thanks again!
See you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants