这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@stevenconner
Copy link
Contributor

No description provided.

metro.config.js Outdated
Comment on lines 45 to 74
server: {
enhanceMiddleware: (middleware) => {
// This only runs once when Metro starts
if (!spawned) {
spawned = true
childProcess = spawn(
"node",
["-e", "require('./standalone-server').startReactotronServer({ port: 9292 })"],
{
stdio: "inherit", // pipe output directly to console
shell: false,
},
)

childProcess.on("exit", (code) => {
console.log(`Child process exited with code ${code}`)
})

// Handle SIGINT (Ctrl+C) to terminate child process
process.on("SIGINT", () => {
if (childProcess) {
console.log("Terminating child process...")
childProcess.kill("SIGINT")
}
})
}

return middleware
},
},
Copy link
Member

@jamonholmgren jamonholmgren Oct 1, 2025

Choose a reason for hiding this comment

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

We can just run it in the metro process, and it'll make this a lot simpler.

Suggested change
server: {
enhanceMiddleware: (middleware) => {
// This only runs once when Metro starts
if (!spawned) {
spawned = true
childProcess = spawn(
"node",
["-e", "require('./standalone-server').startReactotronServer({ port: 9292 })"],
{
stdio: "inherit", // pipe output directly to console
shell: false,
},
)
childProcess.on("exit", (code) => {
console.log(`Child process exited with code ${code}`)
})
// Handle SIGINT (Ctrl+C) to terminate child process
process.on("SIGINT", () => {
if (childProcess) {
console.log("Terminating child process...")
childProcess.kill("SIGINT")
}
})
}
return middleware
},
},

},
},
}

Copy link
Member

Choose a reason for hiding this comment

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

Just add it here:

require('./standalone-server').startReactotronServer({ port: 9292 })

@stevenconner stevenconner merged commit 43ca42b into main Oct 7, 2025
4 checks passed
@stevenconner stevenconner deleted the steve/metro-start-node-process branch October 7, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants