Skip to content

Add edb-proxy API endpoint with CORS support and request handling#11

Merged
Timidan merged 9 commits intomasterfrom
fix/debug
Apr 22, 2026
Merged

Add edb-proxy API endpoint with CORS support and request handling#11
Timidan merged 9 commits intomasterfrom
fix/debug

Conversation

@Timidan
Copy link
Copy Markdown
Owner

@Timidan Timidan commented Apr 15, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 15, 2026 16:06
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web3-toolkit Ready Ready Preview, Comment Apr 18, 2026 4:16am

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds routing for an /api/edb proxy endpoint and updates request path extraction logic to rely on a rewrite-populated path query parameter.

Changes:

  • Added Vercel rewrites for /api/edb and /api/edb/* to forward to an edb-proxy handler.
  • Updated the EDB handler to compute subPath from req.query.path instead of parsing req.url.
  • Adjusted the relative import path for maybeInjectDefaultEtherscanKey.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
vercel.json Adds rewrites intended to route /api/edb traffic through an edb-proxy endpoint.
api/edb/[...path].ts Changes how the downstream sub-path is derived (now from req.query.path) and updates a relative import.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread vercel.json
Comment on lines +5 to +9
"destination": "/api/edb-proxy"
},
{
"source": "/api/edb/:path*",
"destination": "/api/edb-proxy?path=:path*"
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rewrites send /api/edb and /api/edb/* requests to /api/edb-proxy, but the updated request handling logic is in api/edb/[...path].ts (which would normally be reached at /api/edb/*). With these rewrites in place, this handler won’t receive the traffic (and therefore won’t see req.query.path) unless there is a separate /api/edb-proxy serverless function that contains the same logic. Fix by either (a) changing the rewrite destination to /api/edb?path=:path* (or similar) so it hits this file, or (b) moving/duplicating this handler’s logic into the /api/edb-proxy function so the destination matches the implementation.

Suggested change
"destination": "/api/edb-proxy"
},
{
"source": "/api/edb/:path*",
"destination": "/api/edb-proxy?path=:path*"
"destination": "/api/edb?path="
},
{
"source": "/api/edb/:path*",
"destination": "/api/edb?path=:path*"

Copilot uses AI. Check for mistakes.
Refactor and optimize code structure across multiple components
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 65 out of 67 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +44 to +45
export { ensureArray } from "./simulationArtifactTypes";
import { ensureArray } from "./simulationArtifactTypes";
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module both re-exports ensureArray from ./simulationArtifactTypes and also imports the same symbol from the same module for local use. This is redundant and makes the export surface harder to follow. Prefer a single import and then re-export the imported binding (or import under a different name) so there’s only one linkage to ./simulationArtifactTypes.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 69 out of 71 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +542 to +548
// Refine around the chosen Hook to find the best nearby one.
// Skip refinement when the eval-probe already confirmed Hook snapshots
// — they are verified to support eval and the refine batch (~51 RPCs)
// would just add latency without improving the result.
const evalProbeConfirmed = nonEntryHooks.length === 0 && hookIdsInRange.length > 0;
if (nearestFromTargeted !== null && step > 1 && !evalProbeConfirmed) {
const REFINE_WINDOW = 25;
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evalProbeConfirmed is computed as nonEntryHooks.length === 0 && hookIdsInRange.length > 0, which is true even if the eval-probe did not run or found no better Hook snapshots. That can incorrectly skip the refinement batch and leave you with only entry-point Hooks (often empty locals). Consider tracking whether the eval-probe actually produced hookProbeIds.length > 0 and only skipping refinement in that case.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Comment on lines 133 to +139
console.error('[useDebugPrep] auto-connect failed:', err);
if (prepareIdRef.current === prepareId) {
setPrepState((prev) => ({
...prev,
error: 'Live session was evicted before connection completed. Click Open Debugger to use trace-based debugging.',
}));
}
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the auto-connect failure path, prepState stays status: 'ready' while setting only error. This leaves a stale "ready" state even though no session is connected, and downstream logic (e.g., click handlers) may refuse to restart prep because it thinks prep is already ready. Consider setting status: 'failed' (or resetting to idle via cancel) and clearing sessionId/snapshotCount so users can retry preparation cleanly.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Comment on lines +453 to +472
let preppedSessionDead = false;
if (
debugPrepForSimulation?.status === "ready" &&
debugPrepForSimulation.sessionId &&
debugSession?.sessionId !== debugPrepForSimulation.sessionId
) {
try {
await connectToSession({
sessionId: debugPrepForSimulation.sessionId,
rpcPort: 0,
snapshotCount: debugPrepForSimulation.snapshotCount ?? 0,
chainId,
simulationId,
});
openDebugWindow();
return;
} catch (err) {
console.warn("[handleOpenDebug] Failed to connect to prepped session:", err);
preppedSessionDead = true;
}
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If connecting to the "ready" prepped session fails, preppedSessionDead is set and later the code skips startReplayDebugPreparation entirely. This can strand users: the stale prepState remains ready, but no live session is usable and no new prep is started. A safer flow is to call cancelDebugPrep() on failure (or otherwise mark the prepState failed) and then allow startReplayDebugPreparation(simulationId) to run so a new live session can be prepared.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e70d6b6. When connecting to the ready prepped session fails, cancelDebugPrep() is now called to clear the stale ready state, and the !preppedSessionDead guard on startReplayDebugPreparation is removed so a fresh prep can be started automatically.

Comment on lines 519 to 521
if (debugRequested && !preppedSessionDead) {
if (startReplayDebugPreparation(simulationId)) {
showSuccess(
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The debugRequested && !preppedSessionDead guard prevents retrying preparation when the previous ready session was evicted. Instead of skipping prep when preppedSessionDead is true, reset/cancel the stale prep state and proceed with preparation so "Open Debugger" can recover automatically.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already addressed in e70d6b6cancelDebugPrep() is called in the catch block to clear the stale prep state, and the !preppedSessionDead guard was removed from the if (debugRequested) check so startReplayDebugPreparation always runs when appropriate.

Comment thread src/services/DebugBridgeService.ts
Copilot AI review requested due to automatic review settings April 18, 2026 02:39
@Timidan Timidan review requested due to automatic review settings April 18, 2026 02:39
Copilot AI review requested due to automatic review settings April 18, 2026 04:15
@Timidan Timidan review requested due to automatic review settings April 18, 2026 04:15
@Timidan Timidan merged commit 722cb4f into master Apr 22, 2026
3 checks passed
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