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

elaborate on error "Expected Sink" #15234

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

elaborate on error "Expected Sink" #15234

wants to merge 6 commits into from

Conversation

paperdave
Copy link
Member

Consider this code snippet.

let leakedCtrl;
using server = Bun.serve({
  async fetch(req) {
    return new Response(new ReadableStream({
      type: "direct",
      async pull(ctrl) {
        ctrl.write('a');
        await sleep(10);
        ctrl.write('b');
        ctrl.flush();
        leakedCtrl = ctrl;
      },
    } as any));
  },
});
let response = await fetch(server.url);
expect(await response.text()).toBe('ab');
leakedCtrl.write('more');

This used to throw Expected Sink, but now throws a more accurate error message:

17 |     } as any));
18 |   },
19 | });
20 | let response = await fetch(server.url);
21 | expect(await response.text()).toBe('ab');
22 | leakedCtrl.write('more');
                ^
error: This HTTPResponseSink has already been closed. A "direct" ReadableStream terminates its underlying socket once `async pull()` returns.

Closes #10632. the author should add await, an example of this is within ssr.tsx, it uses the controller out of the scope but also contains a promise that pull returns.

image

This PR also fixes the bug causing this, and writes being truncated, in the bake framework for react

@robobun
Copy link

robobun commented Nov 19, 2024

@paperdave, your commit ac110e9 has 25 failures in #6445:

  • test/js/web/fetch/fetch.tls.test.ts - 1 failing on 🍎 14 aarch64
  • test/js/web/fetch/fetch.stream.test.ts - 1 failing on 🍎 14 x64
  • test/js/bun/util/sleep.test.ts - 1 failing on 🐧 10 x64
  • test/integration/next-pages/test/dev-server.test.ts - 1 failing on 🐧 3.20 x64
  • test/integration/next-pages/test/dev-server.test.ts - 1 failing on 🐧 3.20 x64-baseline
  • test/js/bun/http/serve.test.ts - segmentation fault on 🐧 3.20 aarch64
  • test/js/bun/http/serve.test.ts - segmentation fault on 🐧 3.20 x64
  • test/js/bun/http/serve.test.ts - segmentation fault on 🐧 3.20 x64-baseline
  • test/js/bun/http/serve.test.ts - 1 failing on 🍎 14 x64
  • test/js/web/timers/setTimeout.test.js - 1 failing on 🐧 22.04 x64
  • test/integration/next-pages/test/next-build.test.ts - 1 failing on 🐧 20.04 x64
  • test/js/bun/shell/leak.test.ts - timeout on 🐧 10 aarch64
  • test/js/bun/shell/leak.test.ts - timeout on 🐧 10 x64-baseline
  • test/js/bun/shell/leak.test.ts - timeout on 🐧 10 x64
  • test/cli/run/filter-workspace.test.ts - 1 failing on 🐧 10 x64-baseline
  • test/cli/install/bun-link.test.ts - 4 failing on 🐧 3.20 aarch64
  • test/cli/install/bun-link.test.ts - 4 failing on 🐧 3.20 x64
  • test/cli/install/bun-link.test.ts - 4 failing on 🐧 3.20 x64-baseline
  • test/v8/v8.test.ts - timeout on 🐧 20.04 aarch64
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 aarch64
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 x64
  • test/v8/v8.test.ts - 22 failing on 🐧 3.20 x64-baseline
  • test/regression/issue/ctrl-c.test.ts - 1 failing on 🐧 22.04 aarch64
  • test/regression/issue/ctrl-c.test.ts - 1 failing on 🐧 3.20 aarch64
  • test/js/bun/symbols.test.ts - 1 failing on 🐧 10 aarch64
  • test/js/bun/symbols.test.ts - 1 failing on 🐧 10 x64
  • test/js/bun/symbols.test.ts - 1 failing on 🐧 10 x64-baseline
  • test/js/bun/shell/bunshell.test.ts - timeout on 🐧 10 aarch64
  • test/js/bun/shell/bunshell.test.ts - timeout on 🐧 10 x64
  • test/js/bun/shell/bunshell.test.ts - timeout on 🐧 10 x64-baseline
  • test/js/node/child_process/child_process.test.ts - timeout on 🐧 2023 aarch64
  • test/js/node/child_process/child_process.test.ts - 1 failing on 🐧 3.20 aarch64
  • test/js/node/child_process/child_process.test.ts - 1 failing on 🐧 3.20 x64
  • test/js/node/child_process/child_process.test.ts - timeout on 🐧 2023 x64
  • test/js/node/child_process/child_process.test.ts - timeout on 🐧 2023 x64-baseline
  • test/js/node/child_process/child_process.test.ts - 1 failing on 🐧 3.20 x64-baseline
  • test/cli/install/bun-run.test.ts - timeout on 🐧 2023 aarch64
  • test/cli/run/run-crash-handler.test.ts - timeout on 🐧 2023 aarch64
  • test/cli/run/run-crash-handler.test.ts - timeout on 🐧 2023 x64
  • test/cli/run/run-crash-handler.test.ts - timeout on 🐧 2023 x64-baseline
  • test/cli/install/registry/bun-install-registry.test.ts - timeout on 🐧 20.04 aarch64
  • test/cli/install/registry/bun-install-registry.test.ts - timeout on 🐧 22.04 x64
  • test/cli/install/registry/bun-install-registry.test.ts - timeout on 🐧 3.20 x64
  • test/js/bun/spawn/spawn-streaming-stdin.test.ts - 1 failing on 🐧 10 aarch64
  • test/js/bun/spawn/spawn-streaming-stdin.test.ts - 1 failing on 🐧 10 x64-baseline
  • test/js/bun/spawn/spawn-streaming-stdin.test.ts - 1 failing on 🐧 10 x64
  • test/js/bun/spawn/spawn-streaming-stdin.test.ts - 1 failing on 🐧 2023 x64-baseline
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 11 aarch64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 10 aarch64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 12 aarch64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 22.04 aarch64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 2023 aarch64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 3.20 aarch64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 11 x64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 10 x64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 12 x64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 10 x64-baseline
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 11 x64-baseline
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 12 x64-baseline
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 20.04 x64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 22.04 x64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 20.04 x64-baseline
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 22.04 x64-baseline
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 2023 x64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 3.20 x64
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 2023 x64-baseline
  • test/js/node/test/parallel/fs-watch-recursive-linux-parallel-remove.test.js - 1 failing on 🐧 3.20 x64-baseline
  • test/js/third_party/body-parser/express-bun-build-compile.test.ts - 1 failing on 🐧 2023 aarch64
  • test/js/third_party/body-parser/express-bun-build-compile.test.ts - 1 failing on 🐧 2023 x64
  • test/js/third_party/body-parser/express-bun-build-compile.test.ts - 1 failing on 🐧 2023 x64-baseline
  • test/bundler/bundler_compile.test.ts - 1 failing on 🐧 10 aarch64
  • test/bundler/cli.test.ts - 1 failing on 🐧 2023 aarch64
  • test/bundler/cli.test.ts - 1 failing on 🐧 2023 x64
  • test/bundler/cli.test.ts - 1 failing on 🐧 2023 x64-baseline
  • test/js/bun/spawn/spawn.test.ts - timeout on 🪟 2019 x64
  • test/cli/inspect/inspect.test.ts - 1 failing on 🪟 2019 x64
  • Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    TypeError: Expected Sink code: "ERR_INVALID_THIS"
    2 participants