Skip to content

Conversation

@sosukesuzuki
Copy link
Member

Fixes oven-sh/bun#22167

JSC generates bytecode so that async functions defined within built-in JS code return JSInternalPromise instead of the default Promise. This is intentional, but this caused Bun's node:fs/promises exported functions to incorrectly return JSInternalPromise.

This patch changes it to return the appropriate Promise by checking the source URL where the built-in is defined.

Copy link
Collaborator

@Jarred-Sumner Jarred-Sumner left a comment

Choose a reason for hiding this comment

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

node:fs/promises shouldn't be special cased here.

@sosukesuzuki
Copy link
Member Author

node:fs/promises shouldn't be special cased here.

If there are no use cases where we want to use JSInternalPromise in Bun's built-ins, sounds good.

@sosukesuzuki sosukesuzuki force-pushed the fs-promises-should-not-return-internal-promise branch from f51364c to f987d1e Compare August 28, 2025 02:08
@Jarred-Sumner Jarred-Sumner merged commit 09f9aed into main Aug 28, 2025
25 checks passed
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.

import('node:fs/promises').readFile does not return a Promise

3 participants