Remove renderer dependency from script execution#9892
Draft
jackkav wants to merge 1 commit intoKong:developfrom
Draft
Remove renderer dependency from script execution#9892jackkav wants to merge 1 commit intoKong:developfrom
jackkav wants to merge 1 commit intoKong:developfrom
Conversation
- script-executor.ts: accept appendTimelineEntry callback instead of calling appendFile directly; callers supply the write implementation - cancellation.ts: pass fs.promises.appendFile wrapper as appendTimelineEntry in the main-process branch of cancellableRunScript - concurrency.ts: add process.type fork in asyncWorker; renderer path keeps window.main.hiddenBrowserWindow.runScript, main-process path calls runScript directly with appendFile callback - network.ts: add fs.promises.appendFile fallback in tryToExecuteScript when runtime is not provided and process.type !== 'renderer' Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the remaining renderer-only dependency from the Node/main-process script execution path by injecting timeline writes into the Node runner and branching execution so non-renderer contexts can run scripts without window.main.
Changes:
- Updated the Node/main
runScript()implementation to accept an injected timeline append function (instead of calling renderer APIs / directly depending on renderer-side behavior). - Updated concurrency + cancellation script execution to choose between hidden-window execution (renderer) and direct Node execution (non-renderer), including persisting timeline logs via
appendFile. - Added a fallback in
tryToExecuteScript()to persist script logs directly to the timeline file in non-renderer contexts when no runtime is provided.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/insomnia/src/script-executor.ts | Makes Node-runner timeline persistence injectable to remove renderer coupling. |
| packages/insomnia/src/network/network.ts | Adds non-renderer fallback for persisting script logs when runtime isn’t present. |
| packages/insomnia/src/network/concurrency.ts | Branches script execution between hidden-window (renderer) and direct Node execution with timeline writes. |
| packages/insomnia/src/network/cancellation.ts | Routes non-renderer cancellation-path script execution through direct Node runner with timeline writes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
15
to
+22
| export const runScript = async ({ | ||
| script, | ||
| context, | ||
| appendTimelineEntry, | ||
| }: { | ||
| script: string; | ||
| context: RequestContext; | ||
| appendTimelineEntry: (opts: { timelinePath: string; data: string }) => Promise<void>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
runScript()so the Node/main-process runner no longer depends on renderer APIsfs.promises.appendFilefor main-process timeline writes where script execution logs are persistedWhy
This removes the remaining renderer-only dependency from the Node.js script execution path, which unblocks main-process and inso script execution without
window.main.Validation
npm test -w packages/insomnia -- src/network/__tests__/network.test.tsnpm run type-check -w packages/insomnia(blocked by existing worktree/setup issue resolving@react-router/fs-routes, unrelated to this branch)