Skip to content

feat: add request log and inspector API for debugging#61

Open
mvanhorn wants to merge 2 commits intovercel-labs:mainfrom
mvanhorn:feat/request-log
Open

feat: add request log and inspector API for debugging#61
mvanhorn wants to merge 2 commits intovercel-labs:mainfrom
mvanhorn:feat/request-log

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

@mvanhorn mvanhorn commented Apr 8, 2026

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 and GET /_emulate/requests over 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/requests endpoints (GET to read, DELETE to clear). Requests to /_emulate/* are excluded from the log.
  • packages/@emulators/core/src/index.ts: Export RequestLogEntry type
  • packages/emulate/src/api.ts: Added requests() and clearRequests() to Emulator interface
  • packages/emulate/src/__tests__/api.test.ts: 3 new tests covering programmatic log access, clearing, and HTTP endpoints
  • README.md and skills/emulate/SKILL.md: documented the new API

Demo

request-log-demo

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 API
  • clears request log - clearRequests()
  • request log via HTTP endpoints - GET/DELETE /_emulate/requests

This contribution was developed with AI assistance (Claude Code).

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>
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 8, 2026

@mvanhorn is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant