qwik icon indicating copy to clipboard operation
qwik copied to clipboard

[🐞] requestEvent object is undefined in $server `this`

Open himorishige opened this issue 1 year ago • 3 comments

Which component is affected?

Qwik Runtime

Describe the bug

In the following implementation, this in $server should contain requestEvent object, but it can be undefined.

const getData = server$(async function () {
  console.log(this.headers);  // undefined
  await sleep(3000);
  return {
    value: 'data',
  };
});

export default component$(() => {
  const data = useResource$(getData);

  return (
    <div>
      <h1>test</h1>
      <Resource
        value={data}
        onPending={() => <div>loading...</div>} // It doesn't show onPending either.
        onResolved={(data) => {
          return <div>{data.value}</div>;
        }}
      />
    </div>
  );
});

Reproduction

https://stackblitz.com/edit/qwik-starter-go8nyd?file=src%2Froutes%2Ftest%2Findex.tsx

Steps to reproduce

No response

System Info

System:
    OS: macOS 13.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 66.44 MB / 16.00 GB
    Shell: 3.6.0 - /opt/homebrew/bin/fish
  Binaries:
    Node: 16.19.1 - ~/Library/Caches/fnm_multishells/7264_1683436767598/bin/node
    Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/7264_1683436767598/bin/yarn
    npm: 8.19.3 - ~/Library/Caches/fnm_multishells/7264_1683436767598/bin/npm
  Browsers:
    Brave Browser: 112.1.50.121
    Chrome: 112.0.5615.137
    Firefox: 110.0.1
    Safari: 16.4
  npmPackages:
    @builder.io/qwik: 1.1.0 => 1.1.0
    @builder.io/qwik-city: ~1.1.0 => 1.1.0
    undici: 5.22.0 => 5.22.0
    vite: 4.3.5 => 4.3.5

Additional Information

No response

himorishige avatar May 10 '23 10:05 himorishige

(the repro is under /test. The docs say that server$() get the request on this but not here)

wmertens avatar May 10 '23 10:05 wmertens

I will look at this with priority

manucorporat avatar May 10 '23 12:05 manucorporat

I will look at this with priority

Can you take a look at this issue https://github.com/BuilderIO/qwik/issues/5611

notcod avatar Dec 19 '23 16:12 notcod