Skip to content

fix: guard against undefined http plugin in session lifecycle events#187

Open
fdciabdul wants to merge 1 commit intohttptoolkit:mainfrom
fdciabdul:fix/guard-null-http-plugin
Open

fix: guard against undefined http plugin in session lifecycle events#187
fdciabdul wants to merge 1 commit intohttptoolkit:mainfrom
fdciabdul:fix/guard-null-http-plugin

Conversation

@fdciabdul
Copy link

Sessions created without the http plugin (e.g. WebRTC-only or metadata-only sessions via the admin API) crash the server because http.getMockServer() is called unconditionally in both mock-session-started and mock-session-stopping event handlers.

This adds null checks to skip http-dependent background services (Docker interception, WebExtension config) when the http plugin is not present in the session.

Sessions created without the http plugin (e.g. WebRTC-only or
metadata-only sessions via the admin API) crash the server because
`http.getMockServer()` is called unconditionally in both
`mock-session-started` and `mock-session-stopping` event handlers.

This adds null checks to skip http-dependent background services
(Docker interception, WebExtension config) when the http plugin
is not present in the session.
@CLAassistant
Copy link

CLAassistant commented Mar 20, 2026

CLA assistant check
All committers have signed the CLA.

@pimterry
Copy link
Member

Hi @fdciabdul - sessions shouldn't be created without the HTTP plugin, that's not supported. Can you explain more about how that's happening in your case? The right move is probably to fix any bugs which cause that incorrect setup, and maybe to hard-fail up front here immediately in that scenario to make it easier to catch in future.

If the issue is that you're doing custom scripting on top of HTTP Toolkit server, that's not supported. The server is designed to work directly with the UI and nothing else - to keep the codebase manageable and focused it can't support custom configurations like this. This isn't intended as a reusable component, and so its API will change unexpectedly and break for most non-UI use cases.

If you want to build your own custom proxy automation, you should use Mockttp and/or MockRTC directly instead - they're specifically designed for custom setups & automation, and they're very flexible for all sorts of use cases.

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.

3 participants