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

Progress for Next.js #4468

Merged
merged 36 commits into from
Sep 7, 2023
Merged

Progress for Next.js #4468

merged 36 commits into from
Sep 7, 2023

Conversation

paperdave
Copy link
Member

@paperdave paperdave commented Sep 3, 2023

What does this PR do?

  • feat(runtime): implement child_process.fork / ipc channels. Closes Implement child_process.fork() #3620
  • fix(runtime): undefined values in spawn env args no longer be passed
  • chore: remove BUN_OVERRIDE_MODULE_PATH (it doesn't do anything)
  • feat(runtime): implement fs.promises.opendir
  • feat(runtime): implement v8.getHeapStatistics
  • fix(runtime): do not append node: to require.resolve("without_prefix")
  • feat(runtime): implement setter for require('module')._resolveFilename
  • fix(runtime): make fs.WriteStream and NativeWritable function-style classes
  • fix(runtime): do not inline resolved paths into transpiled CommonJS (fixes next.js react duplication bugs)
  • fix(runtime): ensure req.socket === the socket passed to the "upgrade" event.
  • chore(cli): remove bun dev. closes bun run dev acts differently than bun dev #4166
  • feat(cli): make bun create execute create- packages. closes bun create to be compatible with npm create #485
  • chore(cli): make the cli help menus nicer.
  • ... any more?

How did you verify your code works?

I've been testing with Next.js to get it farther.

@codehz
Copy link
Contributor

codehz commented Sep 4, 2023

#4236
will it expose same internal symbol (Symbol(kChannelHandle)) as node does?

@paperdave
Copy link
Member Author

#4236
will it expose same internal symbol (Symbol(kChannelHandle)) as node does?

According to the node docs on IPC:

Accessing the IPC channel fd in any way other than process.send() or using the IPC channel with a child process that is not a Node.js instance is not supported.

The internal implementation I'm working with so far does not look anything like node's at all, so even if this symbol existed with some value, it simply wouldn't work. All of the IPC code is done in native.

This library should use "pipe" with a fourth file descriptor (scroll down in the docs link) instead of hijacking the Node IPC system for messages, it would be much cleaner on their end... however Bun/this per doesn't implement extra fds yet. The only way it would work right now is using stdout+stdin pipes.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2023

@paperdave 11 files with test failures on bun-darwin-x64-baseline:

  • test/js/bun/sqlite/sqlite.test.js
  • test/js/bun/util/filesink.test.ts
  • test/js/node/child_process/child-process-stdio.test.js
  • test/js/node/child_process/child_process.test.ts
  • test/js/node/fs/fs.test.ts
  • test/js/node/http/node-http.test.ts
  • test/js/node/stream/bufferlist.test.ts
  • test/js/third_party/esbuild/esbuild-child_process.test.ts
  • test/js/third_party/webpack/webpack.test.ts
  • test/js/web/fetch/fetch.tls.test.ts
  • test/js/web/timers/setTimeout.test.js

View test output

#d8311f4cae3b6703e1d8e6338a26db7e52ee22f5

@paperdave paperdave changed the title feat(runtime): implement child_process.fork / ipc channels NEXT.JS Sep 5, 2023
src/js/node/fs.promises.ts Outdated Show resolved Hide resolved
@birkskyum
Copy link
Collaborator

Closes #3620

@paperdave paperdave changed the title NEXT.JS Progress for Next.js Sep 6, 2023
@paperdave paperdave marked this pull request as ready for review September 6, 2023 02:41
@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2023

@paperdave 17 files with test failures on bun-darwin-aarch64:

  • test/bundler/bundler_browser.test.ts
  • test/bundler/bundler_minify.test.ts
  • test/bundler/esbuild/default.test.ts
  • test/bundler/esbuild/importstar.test.ts
  • test/bundler/esbuild/splitting.test.ts
  • test/bundler/esbuild/ts.test.ts
  • test/cli/install/bunx.test.ts
  • test/js/bun/resolve/resolve.test.ts
  • test/js/bun/test/test-test.test.ts
  • test/js/node/assert/assert.test.cjs
  • test/js/node/assert/assert.test.ts
  • test/js/node/async_hooks/async_hooks.node.test.ts
  • test/js/node/path/path.test.js
  • test/js/node/process/process-args.test.js
  • test/js/node/util/test-util-types.test.js
  • test/js/node/util/util-promisify.test.js
  • test/js/node/watch/fs.watch.test.ts

View test output

#8a4284d4e501f843fea7a8b65cabce99928862d5

@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

@paperdave 7 files with test failures on linux-x64-baseline:

  • test/js/node/child_process/child-process-stdio.test.js
  • test/js/node/child_process/child_process.test.ts
  • test/js/node/fs/fs.test.ts
  • test/js/node/http/node-http.test.ts
  • test/js/node/stream/bufferlist.test.ts
  • test/js/third_party/esbuild/esbuild-child_process.test.ts
  • test/js/web/fetch/fetch-gzip.test.ts

View test output

#d8311f4cae3b6703e1d8e6338a26db7e52ee22f5

@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

@paperdave 6 files with test failures on linux-x64:

  • test/js/node/child_process/child-process-stdio.test.js
  • test/js/node/child_process/child_process.test.ts
  • test/js/node/fs/fs.test.ts
  • test/js/node/http/node-http.test.ts
  • test/js/node/stream/bufferlist.test.ts
  • test/js/third_party/esbuild/esbuild-child_process.test.ts

View test output

#d8311f4cae3b6703e1d8e6338a26db7e52ee22f5

@@ -2025,7 +2025,7 @@ it("BigIntStats", () => {
it("test syscall errno, issue#4198", () => {
const path = `${tmpdir()}/non-existent-${Date.now()}.txt`;
expect(() => openSync(path, "r")).toThrow("No such file or directory");
expect(() => readSync(2147483640, Buffer.alloc(0))).toThrow("Bad file number");
expect(() => readSync(2147483640, Buffer.alloc(0))).toThrow("EBADF");
Copy link
Collaborator

@Hanaasagi Hanaasagi Sep 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(() => readSync(2147483640, Buffer.alloc(0))).toThrow("EBADF");
if (os.platform() == "darwin") {
expect(() => readSync(2147483640, Buffer.alloc(0))).toThrow("Bad file descriptor");
} else {
expect(() => readSync(2147483640, Buffer.alloc(0))).toThrow("Bad file number");
}

os is not imported.

@paperdave paperdave merged commit 57a0674 into main Sep 7, 2023
11 of 13 checks passed
@paperdave paperdave deleted the dave/ipc branch September 7, 2023 11:58
@birkskyum
Copy link
Collaborator

Tried to test this canary release, but it seems like something broke regarding macos arm64. https://github.com/oven-sh/bun/actions/runs/6109378228/job/16580283046

@Grandnainconnu
Copy link

process.send still not working with Bun 1.0.6 on macos arm64

@paperdave
Copy link
Member Author

process.send is only defined when IPC is enabled. make sure you are using child_processs.fork to enable it, and note it only works for bun <-> bun communication right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants