Subrequest through service binding sent twice?

i am using RR7 for SSR and trying to fetch the same worker that runs RR7. I have set it up so that all requests go through hono first and if they fall through get handled by the rr7 handler. I made sure the loader only runs once, but the logs seem to indicate that two requests are sent? I added a random UUID to the request and its the same UUID on both requests, but the request ID is different.
export async function loader({ context }: Route.LoaderArgs) {
console.log("Loader running from ", new Error().stack);
const res = await context.cloudflare.env.SELF.fetch(
`https://local.worker/api/test?debug=${crypto.randomUUID()}`
);
const data = (await res.json()) as { message: string };
return {
message: data.message,
};
}
export async function loader({ context }: Route.LoaderArgs) {
console.log("Loader running from ", new Error().stack);
const res = await context.cloudflare.env.SELF.fetch(
`https://local.worker/api/test?debug=${crypto.randomUUID()}`
);
const data = (await res.json()) as { message: string };
return {
message: data.message,
};
}
does anyone have an idea what could be causing this? i genuinely dont know since this right now is the only code path where i call the service binding, and its definitely not running twice
5 Replies
uncreative name
uncreative nameOP4w ago
hold on forgot the images
uncreative name
uncreative nameOP4w ago
No description
No description
No description
No description
uncreative name
uncreative nameOP4w ago
ok i think i "solved" it, i just tried making the api route send to an external webhook and it doesnt run twice, it just appears like it does in the dashboard for some reason (and somehow has two request ids?)
olafg
olafg4w ago
Heyo, I think it is just output from the worker console. In my case it outputs two lines, one when the request is received and another for the response
No description
No description
olafg
olafg4w ago
I guess you can also confirm this by checking the $metadata.requestId variable

Did you find this page helpful?