Skip to content

[🐞] requestEvent object is undefined in server$() this #4154

Closed
@himorishige

Description

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

Metadata

Assignees

No one assigned

    Labels

    P4: urgentIf Bug - it makes Qwik unstable and affects the majority of usersTYPE: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions