feat: add onSessionStart/onBeforeSessionEnd/onAfterSessionEnd plugin hooks#275
Conversation
api/src/services/cdp/cdp.service.ts
Outdated
| this.logger, | ||
| ); | ||
|
|
||
| await this.pluginManager.onAfterSessionEnd(sessionConfig); |
There was a problem hiding this comment.
this should be in a finally block incase teardown/relaunch throws
There was a problem hiding this comment.
Now that I've handled the teardown block throws, the idle browser relaunch feels like an independent operational failure unrelated to whether the session ended cleanly or to session itself, so I kept it outside the finally block. WDYT?
2d86162 to
f764c1a
Compare
| } catch (error) { | ||
| await this.pluginManager | ||
| .onAfterSessionEnd(sessionConfig) | ||
| .catch((e) => | ||
| this.logger.error(`[CDPService] onAfterSessionEnd cleanup after failed launch: ${e}`), | ||
| ); | ||
| throw error; |
There was a problem hiding this comment.
I think a finally here works, no need to re-throw. Also the catch shouldn't be needed here either
There was a problem hiding this comment.
With finally it would incorrectly call the onAfterSessionEnd on successful launch when the session is still active right?
There was a problem hiding this comment.
you'll need to await the this.launch(sessionConfig);
960d8f8 to
362b302
Compare
…hooks Introduces three new lifecycle hooks to BasePlugin/PluginManager/CDPService that fire at precise points around a session boundary: - onSessionStart: fires before any launch/reuse work begins - onBeforeSessionEnd: fires before shutdown starts - onAfterSessionEnd: fires after all teardown is complete
362b302 to
9be34c8
Compare
Description
Introduces three new lifecycle hooks to BasePlugin/PluginManager/CDPService that fire at precise points around a session boundary:
Type of Change
Related Issues
Closes #(issue number)
Related to #(issue number)
Changes Made
Testing
Documentation
Code Quality
Breaking Changes
If this is a breaking change, please describe:
Screenshots (if applicable)
Include screenshots or GIFs for UI changes.
Additional Notes
Any additional information, concerns, or context for reviewers.
Reviewer Checklist