Conversation
anonrig
left a comment
There was a problem hiding this comment.
Small comments. The current test failure is due to test/message/node_run_non_existent.out.
After these small changes, I think we can ship it! Thank you for your contribution (and welcome!)
Co-authored-by: Yagiz Nizipli <[email protected]>
Co-authored-by: Yagiz Nizipli <[email protected]>
Co-authored-by: Yagiz Nizipli <[email protected]>
|
Compilation error on Windows: |
|
I'll check these compilation errors. |
|
@StefanStojanovic I believe these likely came from removing some .c_str() calls |
|
The issue here is the character type of From fc0f3ed6c020eb0180065bc89bce026b68e2216f Mon Sep 17 00:00:00 2001
From: StefanStojanovic <[email protected]>
Date: Tue, 9 Jul 2024 20:23:48 +0200
Subject: [PATCH 1/1] ProcessRunner::Run Windows fix
---
src/node_task_runner.cc | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/node_task_runner.cc b/src/node_task_runner.cc
index cb2defee973..0c37b1072d6 100644
--- a/src/node_task_runner.cc
+++ b/src/node_task_runner.cc
@@ -207,7 +207,15 @@ void ProcessRunner::OnExit(int64_t exit_status, int term_signal) {
void ProcessRunner::Run() {
// keeps the string alive until destructor
auto cwd = package_json_path_.parent_path();
+#ifdef _WIN32
+ std::wstring cwd_wstr = cwd.wstring();
+ int size = WideCharToMultiByte(CP_UTF8, 0, cwd_wstr.c_str(), -1, nullptr, 0, nullptr, nullptr);
+ std::string cwd_string(size, 0);
+ WideCharToMultiByte(CP_UTF8, 0, cwd_wstr.c_str(), -1, &cwd_string[0], size, nullptr, nullptr);
+ options_.cwd = cwd_string.c_str();
+#else
options_.cwd = cwd.c_str();
+#endif
if (int r = uv_spawn(loop_, &process_, &options_)) {
fprintf(stderr, "Error: %s\n", uv_strerror(r));
}
--
2.45.2.windows.1
|
|
@StefanStojanovic I'm ok with an ifdef but we would want to add it to quite a few places according to above |
If you are referring to the #53600 (comment), other logs are just warnings so at least the compilation would succeed. A potential problem is that those logs would be unusable. The good thing is that all of the warnings are from the same function One question I have though - what would be the easiest way to reproduce showing some of these logs? |
|
You can run path.string() and convert the filesystem path to a std::string. It will create an unnecessary string and copy operation but it will work for both operating systems without any ifdef. |
|
@StefanStojanovic is currently on vacation so I will be handling this in the meantime. Thanks @anonrig, I've used the function that you've provided. @bmeck I'm able to compile with the patch below locally. If this fix makes sense to you, feel free to apply it. diff --git a/src/node_task_runner.cc b/src/node_task_runner.cc
index cb2defee973..429b72e3e5f 100644
--- a/src/node_task_runner.cc
+++ b/src/node_task_runner.cc
@@ -207,7 +207,7 @@ void ProcessRunner::OnExit(int64_t exit_status, int term_signal) {
void ProcessRunner::Run() {
// keeps the string alive until destructor
auto cwd = package_json_path_.parent_path();
- options_.cwd = cwd.c_str();
+ options_.cwd = cwd.string().c_str();
if (int r = uv_spawn(loop_, &process_, &options_)) {
fprintf(stderr, "Error: %s\n", uv_strerror(r));
}
@@ -256,7 +256,7 @@ void RunTask(std::shared_ptr<InitializationResultImpl> result,
auto package_json = FindPackageJson(cwd);
if (!package_json.has_value()) {
- fprintf(stderr, "Can't find package.json for directory %s\n", cwd.c_str());
+ fprintf(stderr, "Can't find package.json for directory %s\n", cwd.string().c_str());
result->exit_code_ = ExitCode::kGenericUserError;
return;
}
@@ -273,7 +273,7 @@ void RunTask(std::shared_ptr<InitializationResultImpl> result,
simdjson::error_code error = json_parser.iterate(raw_json).get(document);
if (error) {
- fprintf(stderr, "Can't parse %s\n", path.c_str());
+ fprintf(stderr, "Can't parse %s\n", path.string().c_str());
result->exit_code_ = ExitCode::kGenericUserError;
return;
}
@@ -283,9 +283,9 @@ void RunTask(std::shared_ptr<InitializationResultImpl> result,
if (root_error == simdjson::error_code::INCORRECT_TYPE) {
fprintf(stderr,
"Root value unexpected not an object for %s\n\n",
- path.c_str());
+ path.string().c_str());
} else {
- fprintf(stderr, "Can't parse %s\n", path.c_str());
+ fprintf(stderr, "Can't parse %s\n", path.string().c_str());
}
result->exit_code_ = ExitCode::kGenericUserError;
return;
@@ -294,7 +294,7 @@ void RunTask(std::shared_ptr<InitializationResultImpl> result,
// If package_json object doesn't have "scripts" field, throw an error.
simdjson::ondemand::object scripts_object;
if (main_object["scripts"].get_object().get(scripts_object)) {
- fprintf(stderr, "Can't find \"scripts\" field in %s\n", path.c_str());
+ fprintf(stderr, "Can't find \"scripts\" field in %s\n", path.string().c_str());
result->exit_code_ = ExitCode::kGenericUserError;
return;
}
@@ -308,13 +308,13 @@ void RunTask(std::shared_ptr<InitializationResultImpl> result,
"Script \"%.*s\" is unexpectedly not a string for %s\n\n",
static_cast<int>(command_id.size()),
command_id.data(),
- path.c_str());
+ path.string().c_str());
} else {
fprintf(stderr,
"Missing script: \"%.*s\" for %s\n\n",
static_cast<int>(command_id.size()),
command_id.data(),
- path.c_str());
+ path.string().c_str());
fprintf(stderr, "Available scripts are:\n");
// Reset the object to iterate over it again
|
|
Needs to be rebased with new CI runs. Removed the author ready and commit queue labels. |
PR-URL: #54949 Refs: #53600 Reviewed-By: Matthew Aitken <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
PR-URL: #54949 Refs: #53600 Reviewed-By: Matthew Aitken <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
PR-URL: nodejs#54949 Refs: nodejs#53600 Reviewed-By: Matthew Aitken <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
PR-URL: nodejs#54949 Refs: nodejs#53600 Reviewed-By: Matthew Aitken <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
No description provided.