-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
CONOUT$ no longer available for Node 22? #54161
Comments
@nodejs/fs PTAL |
I hit the same issue. I think it makes sense to move this to nodejs/issues. |
Edit: it does. |
The following patch cannot land but fixes the issue. diff --git a/src/node_file.cc b/src/node_file.cc
index a86482b194..0cc5a821cd 100644
--- a/src/node_file.cc
+++ b/src/node_file.cc
@@ -2137,7 +2137,7 @@ static void Open(const FunctionCallbackInfo<Value>& args) {
BufferValue path(env->isolate(), args[0]);
CHECK_NOT_NULL(*path);
- ToNamespacedPath(env, &path);
+ // ToNamespacedPath(env, &path);
CHECK(args[1]->IsInt32());
const int flags = args[1].As<Int32>()->Value();
#52135 should have been marked as semver-major. |
I think there is currently no workaround. |
cc: @nodejs/platform-windows @huseyinacacak-janea |
I don't understand why you say that. The PR was supposed to be only refactoring. If it changed the behavior on Windows, it should be fixed or reverted. |
The problem is that userland modules uses |
|
Fair enough. I wonder if the trailing slash added by diff --git a/lib/path.js b/lib/path.js
index f72f5835e9..ce91895071 100644
--- a/lib/path.js
+++ b/lib/path.js
@@ -320,7 +320,7 @@ const win32 = {
isPathSeparator);
return resolvedAbsolute ?
- `${resolvedDevice}\\${resolvedTail}` :
+ `${resolvedDevice}${resolvedTail ? '\\' + resolvedTail : ''}` :
`${resolvedDevice}${resolvedTail}` || '.';
},
diff --git a/src/path.cc b/src/path.cc
index fade21c8af..98b420d55a 100644
--- a/src/path.cc
+++ b/src/path.cc
@@ -221,7 +221,11 @@ std::string PathResolve(Environment* env,
resolvedTail = NormalizeString(resolvedTail, !resolvedAbsolute, "\\");
if (resolvedAbsolute) {
- return resolvedDevice + "\\" + resolvedTail;
+ if (!resolvedTail.empty()) {
+ return resolvedDevice + "\\" + resolvedTail;
+ }
+
+ return resolvedDevice;
}
if (!resolvedDevice.empty() || !resolvedTail.empty()) {
|
The above patch breaks the following expectation path.win32.toNamespacedPath('c://') === '\\\\?\\c:\\'; I'm out of ideas. |
I'll take a look, but it seems like the change fixed a bypass. We can add a specific bypass to ToNamespacedPath for this value? |
I've also created https://github.com/lpinca/fs-open-sync. |
I’ve submitted a PR to fix the issue at #54367. If anyone has a moment, I would greatly appreciate your review. |
Node.js Version
v22.4.1
NPM Version
v10.8.1
Operating System
Windows 11
Subsystem
fs, process
Description
I am trying to fix some code for compatibility with node 22 that writes directly to the terminal. For unix-like OS's, things work fine due to
/dev/tty
, but for Windows, the code usesprocess.binding('fs')
hackery to open theconout$
magic file. However, this no-longer works in node 22, which treatsconout$
as a regular filename and of course cannot find it.Is there a way to make something like this work for node 22? Is there finally a cleaner option to writing to the Windows console directly without using stdout?
Minimal Reproduction
Using node 22, on Windows run this code:
Output
Before You Submit
The text was updated successfully, but these errors were encountered: