diff --git a/src/api/exceptions.cc b/src/api/exceptions.cc index 1b9b308ad89..871fe78de95 100644 --- a/src/api/exceptions.cc +++ b/src/api/exceptions.cc @@ -157,14 +157,14 @@ Local UVException(Isolate* isolate, static const char* winapi_strerror(const int errorno, bool* must_free) { char* errmsg = nullptr; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - nullptr, - errorno, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - reinterpret_cast(&errmsg), - 0, - nullptr); + FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + nullptr, + errorno, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + reinterpret_cast(&errmsg), + 0, + nullptr); if (errmsg) { *must_free = true; diff --git a/test/parallel/test-debug-process.js b/test/parallel/test-debug-process.js new file mode 100644 index 00000000000..0d10a15e2ee --- /dev/null +++ b/test/parallel/test-debug-process.js @@ -0,0 +1,21 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const child = require('child_process'); + +if (!common.isWindows) { + common.skip('This test is specific to Windows to test winapi_strerror'); +} + +// Ref: https://github.com/nodejs/node/issues/23191 +// This test is specific to Windows. + +const cp = child.spawn('pwd'); + +cp.on('exit', common.mustCall(function() { + try { + process._debugProcess(cp.pid); + } catch (error) { + assert.strictEqual(error.message, 'The system cannot find the file specified.'); + } +}));