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

binding: mock readFileSync #378

Closed
wants to merge 1 commit into from
Closed

Conversation

Rugvip
Copy link
Contributor

@Rugvip Rugvip commented Sep 5, 2023

Potential fix for #377

Most of it is explained in the comment, but to reiterate: we can mock the optimized readFileSync method introduced in Node v20 by calling the original readFileSync but bypassing the optimization by calling .toString('utf8') manually afterwards instead.

I figured it's safe to ignore the flag since it's just mocked reads anyway, let's me know if that needs a fix.

@chadlwilson
Copy link

Whereas it was working fine on Node 20.7.0, I think this workaround no longer work entirely correctly on its own with Node 20.8.0+.

Based on the changelog at https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V20.md#2023-09-28-version-2080-current-ruyadorno , I am guessing it's some of the changes such as nodejs/node#49593 or nodejs/node#49691

@Rugvip
Copy link
Contributor Author

Rugvip commented Oct 6, 2023

Closing this since there are additional breaking change in Node.js v20.8.0, and we are now moving away from mock-fs in favor of temporary mock directories. (backstage/backstage#20436 has some extra context in case anyone is interested)

@Rugvip Rugvip closed this Oct 6, 2023
@Rugvip Rugvip deleted the read-file-sync branch October 6, 2023 20:21
@Rugvip Rugvip restored the read-file-sync branch October 6, 2023 20:24
@Rugvip Rugvip deleted the read-file-sync branch October 6, 2023 20:24
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.

2 participants