feat: add request log and inspector API for debugging#61
Open
mvanhorn wants to merge 2 commits intovercel-labs:mainfrom
Open
feat: add request log and inspector API for debugging#61mvanhorn wants to merge 2 commits intovercel-labs:mainfrom
mvanhorn wants to merge 2 commits intovercel-labs:mainfrom
Conversation
Add a request logging middleware to the core server that records every API call (method, path, status, duration, timestamp). Expose the log via GET /_emulate/requests and DELETE /_emulate/requests endpoints, plus requests() and clearRequests() methods on the Emulator interface. Uses a ring buffer of 1000 entries to bound memory. Requests to /_emulate/* control endpoints are excluded from the log. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
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
Add request logging middleware that records every API call to an emulated service. Each request is logged with method, path, status code, duration, and timestamp. The log is accessible via
emulator.requests()in the programmatic API andGET /_emulate/requestsover HTTP.Why this matters
When an integration test fails against emulate, there is currently no way to see what requests hit the emulated service or what responses were returned. Mockoon and MSW both provide request introspection. This is essential for debugging test failures, especially when running multiple services.
Changes
packages/@emulators/core/src/server.ts: Added request logging middleware (ring buffer, 1000 entries max) and/_emulate/requestsendpoints (GET to read, DELETE to clear). Requests to/_emulate/*are excluded from the log.packages/@emulators/core/src/index.ts: ExportRequestLogEntrytypepackages/emulate/src/api.ts: Addedrequests()andclearRequests()toEmulatorinterfacepackages/emulate/src/__tests__/api.test.ts: 3 new tests covering programmatic log access, clearing, and HTTP endpointsREADME.mdandskills/emulate/SKILL.md: documented the new APIDemo
Makes a POST request, inspects the request log showing method/path/status/duration, then clears it.
Testing
All 7 tests pass (4 existing + 3 new):
records requests in the log- programmatic APIclears request log- clearRequests()request log via HTTP endpoints- GET/DELETE /_emulate/requestsThis contribution was developed with AI assistance (Claude Code).