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

fix: don't crash when fs.readFile returns promise from another realm #18416

Merged
merged 2 commits into from
May 7, 2024

Conversation

mdjermanovic
Copy link
Member

@mdjermanovic mdjermanovic commented May 4, 2024

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[X] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

Fixes #18407

What changes did you make? (Give an overview)

Updated @humanwhocodes/retry dependency to the latest v0.2.4 that includes the fix for #18407 and added a test that fails with v0.2.3.

Also updates lib/eslint/eslint.js to use require("fs/promises") instead of require("fs").promises.

Is there anything you'd like reviewers to focus on?

@mdjermanovic mdjermanovic requested a review from a team as a code owner May 4, 2024 19:57
@eslint-github-bot eslint-github-bot bot added the bug ESLint is working incorrectly label May 4, 2024
@github-actions github-actions bot added cli Relates to ESLint's command-line interface core Relates to ESLint's core APIs and features labels May 4, 2024
@mdjermanovic mdjermanovic added the accepted There is consensus among the team that this change meets the criteria for inclusion label May 4, 2024
Copy link

netlify bot commented May 4, 2024

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit 0b8b96b
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/66389b421db8b00008923f53
😎 Deploy Preview https://deploy-preview-18416--docs-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -1057,6 +1057,61 @@ describe("ESLint", () => {
await assert.rejects(async () => await eslint.lintFiles(["lib/cli.js"]), /Expected object with parse\(\) or parseForESLint\(\) method/u);
});

// https://github.com/eslint/eslint/issues/18407
it("should work in case when `fs.readFile()` returns an object that is not an instance of Promise from this realm", async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe fs.promises.readFile() or fsp.readFile()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to fsp.readFile() in 0b8b96b.

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Just waiting for the patch release period to pass.

@aladdin-add aladdin-add merged commit 37eba48 into main May 7, 2024
19 checks passed
@aladdin-add aladdin-add deleted the issue18407 branch May 7, 2024 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly cli Relates to ESLint's command-line interface core Relates to ESLint's core APIs and features
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Bug: An error occurs when invoking ESLint#lintFiles() in Jest
4 participants