feat: add hidden browser window for execution [INS-3378]#6897
feat: add hidden browser window for execution [INS-3378]#6897
Conversation
packages/insomnia-smoke-test/tests/smoke/utility-process.test.ts
Outdated
Show resolved
Hide resolved
|
FYI - Electron supports utility process out of the box now - https://www.electronjs.org/docs/latest/api/utility-process We can take a look at Bloom's implementation. Theirs is pretty straightforward and clean - https://github.com/bloomwalletio/bloom/blob/f69868fc7003248fadb583d3a03a162d5f6d289b/packages/desktop/lib/electron/processes/main.process.ts#L287 |
|
@marckong Cool, how does it handle Node APIs? Let's have a discussion. |
| async (tc: any) => { | ||
| window.postMessage( | ||
| { | ||
| action: 'message-event://utility.process/debug', |
There was a problem hiding this comment.
message names are basically named in this way protocol://target/action and it might help to understand the workflow.
packages/insomnia-smoke-test/tests/smoke/environment-editor-interactions.test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
can you provide reference documentation for the utility process implementation?
The why of the PR is not particularly clear in the description, so it would be helpful for the future maintainers to list a few thoughts about why you chose this approach and what else you considered.
|
@jackkav It makes sense, I have one and let me update it. |
|
TODO: (perhaps out of scope) what happens when the hidden window is closed unexpectedly |
jackkav
left a comment
There was a problem hiding this comment.
an idea for exposing the issues with hidden browser window, would be to allow the insomnia object to be useable inside an insomnia test. That was we can send some simple calculation over the message port in this scope and playwright test it.
…re are multiple windows now
| code: string, | ||
| context: object, | ||
| ): Promise<RawObject | undefined> => { | ||
| if (!this.hiddenBrowserWindowPort) { |
There was a problem hiding this comment.
@jackkav Hidden window health checking is a good point. Current implementation mainly takes care it by following parts:
- when the hidden browser window is closed, it will send out a
message-channel://consumers/closemessage here: https://github.com/Kong/insomnia/pull/6897/files#diff-cf4ec28f994de79ba2cb3c9d96b57c198e7e3ab48e2b1067c5d267fba521f884R74 - the
WindowMessageHandler(of the main renderer) will receive this message, and clean and close the channel - And in this place, before running the pre-request script, it checks if port is invalid, if so, it tries to restart the hidden window immediately
It is an interesting topic let me know if you have thoughts on it and we can have a discussion.
Changes:
variablescollectionVariablesenvironmentiterationDatainfoHow to play with it:
await window.hiddenBrowserWindow.start();TODO:
test.ts