Skip to content

Conversation

@github-actionsgithub-actionsbot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels May 8, 2021
constreadOnlyOption={mode: fs.constants.O_RDONLY,flag: 'r'};
fs.writeFile(filename3,s,readOnlyOption,common.expectsError({
code: 'EBADF',
message: 'EBADF: bad file descriptor, write'
Copy link
Member

Choose a reason for hiding this comment

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

Not a change to make in this PR, but I wonder if that error message could be improved. Unless I'm misunderstanding, the problem from the user perspective is mode/permissions and not that the file descriptor is bad.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Agreed. Since writeFile(fd) and writeFile(path) share the same util function writeAll, this change may need a refactor.

I'll open an issue to track it and look into it later.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

According to https://man7.org/linux/man-pages/man2/write.2.html:

  • EBADF: fd is not a valid file descriptor or is not open for writing.
  • EPERM: The operation was prevented by a file seal; see fcntl(2).

Considering that the file has been opened in the read-only mode and the program is attempting to write to it, isn't EBADF more appropriate here?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I guess the point is that it's a writeFile operation in the user perspective, but the current error is about file descriptor, which may causes confusing.

Copy link
Member

Choose a reason for hiding this comment

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

This function just reflects the error that is returned from uv_fs_write, which again reflects the error the OS returns. I don't think we replace the error codes for the other functions, so doing it for this particular function feels a little odd, don't you think?

Copy link
Member

Choose a reason for hiding this comment

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

@pd4d10 This test is failing for Windows. Could you please update it to expect an EPERM for Windows?

@mhdawsonmhdawson added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 14, 2021
@nodejs-github-bot

This comment has been minimized.

@mhdawson

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@RaisinTenRaisinTen removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 18, 2021
@RaisinTen
Copy link
Member

Removing the author-ready for now as there is a failure on Windows. Will add it back in after it is fixed.

@nodejs-github-bot

This comment has been minimized.

@RaisinTenRaisinTen added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 20, 2021
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented May 21, 2021

@jasnell
Copy link
Member

Landed in a1f590e

@jasnelljasnell closed this May 21, 2021
jasnell pushed a commit that referenced this pull request May 21, 2021
@pd4d10pd4d10 deleted the patch-test-fs branch May 22, 2021 01:24
danielleadams pushed a commit that referenced this pull request May 31, 2021
@danielleadamsdanielleadams mentioned this pull request May 31, 2021
@richardlau
Copy link
Member

This lands cleanly on v14.x-staging but the modified test fails

=== release test-fs-writefile-with-fd === Path: parallel/test-fs-writefile-with-fd /home/rlau/sandbox/github/trees/v14.x-staging/test/parallel/test-fs-writefile-with-fd.js:74 const controller = new AbortController(); ^ ReferenceError: AbortController is not defined at Object.<anonymous> (/home/rlau/sandbox/github/trees/v14.x-staging/test/parallel/test-fs-writefile-with-fd.js:74:22) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) 

I tried adding

// Flags: --experimental-abortcontroller 

at the beginning of the test file but still get an error:

$ node test/parallel/test-fs-writefile-with-fd.js NOTE: The test started as a child_process using these flags: [ '--experimental-abortcontroller' ] Use NODE_SKIP_FLAG_CHECK to run the test with the original flags. (node:553301) ExperimentalWarning: AbortController is an experimental feature. This feature could change at any time (Use `node --trace-warnings ...` to show where the warning was created) /home/rlau/sandbox/github/trees/v14.x-staging/test/common/index.js:577 assert.strictEqual(descriptor.enumerable, false); ^ TypeError: Cannot read property 'enumerable' of undefined at /home/rlau/sandbox/github/trees/v14.x-staging/test/common/index.js:577:35 at /home/rlau/sandbox/github/trees/v14.x-staging/test/common/index.js:376:15 at writeAll (fs.js:1449:7) at Object.writeFile (fs.js:1494:5) at /home/rlau/sandbox/github/trees/v14.x-staging/test/parallel/test-fs-writefile-with-fd.js:80:8 at /home/rlau/sandbox/github/trees/v14.x-staging/test/common/index.js:341:17 at /home/rlau/sandbox/github/trees/v14.x-staging/test/common/index.js:376:15 at FSReqCallback.oncomplete (fs.js:180:23) 

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.needs-ciPRs that need a full CI run.testIssues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@pd4d10@nodejs-github-bot@mhdawson@RaisinTen@jasnell@richardlau@Trott