mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 05:38:47 +02:00
worker: fix worker name with \0
Some checks failed
Coverage Windows / coverage-windows (push) Waiting to run
Coverage Linux / coverage-linux (push) Failing after 1m29s
Coverage Linux (without intl) / coverage-linux-without-intl (push) Failing after 1m29s
Linters / lint-cpp (push) Successful in 3m46s
Test and upload documentation to artifacts / build-docs (push) Failing after 5m35s
Linters / lint-py (push) Successful in 2m40s
Linters / lint-sh (push) Failing after 1m25s
Linters / lint-addon-docs (push) Successful in 2m20s
Linters / format-cpp (push) Has been skipped
Linters / lint-yaml (push) Successful in 2m13s
Linters / lint-codeowners (push) Failing after 57s
Linters / lint-pr-url (push) Has been skipped
Linters / lint-readme (push) Successful in 1m26s
Notify on Push / Notify on Force Push on `main` (push) Has been skipped
Notify on Push / Notify on Push on `main` that lacks metadata (push) Has been skipped
Scorecard supply-chain security / Scorecard analysis (push) Failing after 53s
Linters / lint-js-and-md (push) Failing after 19m26s
Some checks failed
Coverage Windows / coverage-windows (push) Waiting to run
Coverage Linux / coverage-linux (push) Failing after 1m29s
Coverage Linux (without intl) / coverage-linux-without-intl (push) Failing after 1m29s
Linters / lint-cpp (push) Successful in 3m46s
Test and upload documentation to artifacts / build-docs (push) Failing after 5m35s
Linters / lint-py (push) Successful in 2m40s
Linters / lint-sh (push) Failing after 1m25s
Linters / lint-addon-docs (push) Successful in 2m20s
Linters / format-cpp (push) Has been skipped
Linters / lint-yaml (push) Successful in 2m13s
Linters / lint-codeowners (push) Failing after 57s
Linters / lint-pr-url (push) Has been skipped
Linters / lint-readme (push) Successful in 1m26s
Notify on Push / Notify on Force Push on `main` (push) Has been skipped
Notify on Push / Notify on Push on `main` that lacks metadata (push) Has been skipped
Scorecard supply-chain security / Scorecard analysis (push) Failing after 53s
Linters / lint-js-and-md (push) Failing after 19m26s
PR-URL: https://github.com/nodejs/node/pull/59214 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
parent
afc5893309
commit
9ec68afdc5
8 changed files with 33 additions and 15 deletions
|
@ -532,8 +532,19 @@ NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
|
|||
|
||||
NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
|
||||
Environment* env, ThreadId thread_id, const char* url, const char* name) {
|
||||
CHECK_NOT_NULL(env);
|
||||
if (url == nullptr) url = "";
|
||||
if (name == nullptr) name = "";
|
||||
std::string_view url_view(url);
|
||||
std::string_view name_view(name);
|
||||
return GetInspectorParentHandle(env, thread_id, url_view, name_view);
|
||||
}
|
||||
|
||||
NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
|
||||
Environment* env,
|
||||
ThreadId thread_id,
|
||||
std::string_view url,
|
||||
std::string_view name) {
|
||||
CHECK_NOT_NULL(env);
|
||||
CHECK_NE(thread_id.id, static_cast<uint64_t>(-1));
|
||||
if (!env->should_create_inspector()) {
|
||||
return nullptr;
|
||||
|
|
|
@ -57,10 +57,10 @@ class WorkerFinishedRequest : public Request {
|
|||
|
||||
ParentInspectorHandle::ParentInspectorHandle(
|
||||
uint64_t id,
|
||||
const std::string& url,
|
||||
std::string_view url,
|
||||
std::shared_ptr<MainThreadHandle> parent_thread,
|
||||
bool wait_for_connect,
|
||||
const std::string& name,
|
||||
std::string_view name,
|
||||
std::shared_ptr<NetworkResourceManager> network_resource_manager)
|
||||
: id_(id),
|
||||
url_(url),
|
||||
|
@ -104,8 +104,8 @@ void WorkerManager::WorkerStarted(uint64_t session_id,
|
|||
|
||||
std::unique_ptr<ParentInspectorHandle> WorkerManager::NewParentHandle(
|
||||
uint64_t thread_id,
|
||||
const std::string& url,
|
||||
const std::string& name,
|
||||
std::string_view url,
|
||||
std::string_view name,
|
||||
std::shared_ptr<NetworkResourceManager> network_resource_manager) {
|
||||
bool wait = !delegates_waiting_on_start_.empty();
|
||||
return std::make_unique<ParentInspectorHandle>(
|
||||
|
|
|
@ -57,14 +57,14 @@ class ParentInspectorHandle {
|
|||
public:
|
||||
ParentInspectorHandle(
|
||||
uint64_t id,
|
||||
const std::string& url,
|
||||
std::string_view url,
|
||||
std::shared_ptr<MainThreadHandle> parent_thread,
|
||||
bool wait_for_connect,
|
||||
const std::string& name,
|
||||
std::string_view name,
|
||||
std::shared_ptr<NetworkResourceManager> network_resource_manager);
|
||||
~ParentInspectorHandle();
|
||||
std::unique_ptr<ParentInspectorHandle> NewParentInspectorHandle(
|
||||
uint64_t thread_id, const std::string& url, const std::string& name) {
|
||||
uint64_t thread_id, std::string_view url, std::string_view name) {
|
||||
return std::make_unique<ParentInspectorHandle>(
|
||||
thread_id, url, parent_thread_, wait_, name, network_resource_manager_);
|
||||
}
|
||||
|
@ -97,8 +97,8 @@ class WorkerManager : public std::enable_shared_from_this<WorkerManager> {
|
|||
|
||||
std::unique_ptr<ParentInspectorHandle> NewParentHandle(
|
||||
uint64_t thread_id,
|
||||
const std::string& url,
|
||||
const std::string& name,
|
||||
std::string_view url,
|
||||
std::string_view name,
|
||||
std::shared_ptr<NetworkResourceManager> network_resource_manager);
|
||||
void WorkerStarted(uint64_t session_id, const WorkerInfo& info, bool waiting);
|
||||
void WorkerFinished(uint64_t session_id);
|
||||
|
|
|
@ -1155,7 +1155,7 @@ void Agent::SetParentHandle(
|
|||
}
|
||||
|
||||
std::unique_ptr<ParentInspectorHandle> Agent::GetParentHandle(
|
||||
uint64_t thread_id, const std::string& url, const std::string& name) {
|
||||
uint64_t thread_id, std::string_view url, std::string_view name) {
|
||||
THROW_IF_INSUFFICIENT_PERMISSIONS(parent_env_,
|
||||
permission::PermissionScope::kInspector,
|
||||
"GetParentHandle",
|
||||
|
|
|
@ -94,8 +94,9 @@ class Agent {
|
|||
void DisableAsyncHook();
|
||||
|
||||
void SetParentHandle(std::unique_ptr<ParentInspectorHandle> parent_handle);
|
||||
std::unique_ptr<ParentInspectorHandle> GetParentHandle(
|
||||
uint64_t thread_id, const std::string& url, const std::string& name);
|
||||
std::unique_ptr<ParentInspectorHandle> GetParentHandle(uint64_t thread_id,
|
||||
std::string_view url,
|
||||
std::string_view name);
|
||||
|
||||
// Called to create inspector sessions that can be used from the same thread.
|
||||
// The inspector responds by using the delegate to send messages back.
|
||||
|
|
|
@ -713,6 +713,12 @@ NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
|
|||
const char* child_url,
|
||||
const char* name);
|
||||
|
||||
NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
|
||||
Environment* parent_env,
|
||||
ThreadId child_thread_id,
|
||||
std::string_view child_url,
|
||||
std::string_view name);
|
||||
|
||||
struct StartExecutionCallbackInfo {
|
||||
v8::Local<v8::Object> process_object;
|
||||
v8::Local<v8::Function> native_require;
|
||||
|
|
|
@ -104,7 +104,7 @@ Worker::Worker(Environment* env,
|
|||
if (env->permission()->is_granted(
|
||||
env, node::permission::PermissionScope::kInspector)) {
|
||||
inspector_parent_handle_ =
|
||||
GetInspectorParentHandle(env, thread_id_, url.c_str(), name.c_str());
|
||||
GetInspectorParentHandle(env, thread_id_, url, name);
|
||||
}
|
||||
|
||||
argv_ = std::vector<std::string>{env->argv()[0]};
|
||||
|
|
|
@ -17,7 +17,7 @@ if (!isMainThread) {
|
|||
const assert = require('assert');
|
||||
|
||||
if (isMainThread) {
|
||||
const name = 'Hello Thread';
|
||||
const name = 'Hello\0Thread';
|
||||
const expectedTitle = `[worker 1] ${name}`;
|
||||
const worker = new Worker(fixtures.path('worker-name.js'), {
|
||||
name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue