Is that just by running the constructor

Is that just by running the constructor? What is the instance trying to do when it errors like that
17 Replies
jcheese
jcheese4w ago
well i have this:
try {
const characterStub = await getAgentByName<Env, CharacterAgent>(
c.env.CharacterAgent,
name,
);

return await characterStub.onRequest(c.req.raw);
} catch (e: any) {
return c.json({
success: false,
error: e.message,
});
}
try {
const characterStub = await getAgentByName<Env, CharacterAgent>(
c.env.CharacterAgent,
name,
);

return await characterStub.onRequest(c.req.raw);
} catch (e: any) {
return c.json({
success: false,
error: e.message,
});
}
getting {"success":false,"error":"Internal error in Durable Object storage caused object to be reset."} its the same as this https://discord.com/channels/595317990191398933/1366937630914248724
1984 Ford Laser
1984 Ford LaserOP4w ago
If you just run a simple function like a console.log() does it still error out?
jcheese
jcheese4w ago
inside onRequest?
1984 Ford Laser
1984 Ford LaserOP4w ago
well what is onRequest doing currently?
jcheese
jcheese4w ago
onRequest(request: Request): Response | Promise<Response> {
console.log('got request:', request);
return new Response('Hello from Agent!');
}
onRequest(request: Request): Response | Promise<Response> {
console.log('got request:', request);
return new Response('Hello from Agent!');
}
this is it
1984 Ford Laser
1984 Ford LaserOP4w ago
Is c your ctx object?
jcheese
jcheese4w ago
yeah. using hono
1984 Ford Laser
1984 Ford LaserOP4w ago
isn't env, specifically env.characterAgent separate from ctx? https://developers.cloudflare.com/agents/api-reference/calling-agents/ async fetch(request, env, ctx):
jcheese
jcheese4w ago
its hono. export const adminApi = new Hono<{ Bindings: Env; }>() ctx is hono context
1984 Ford Laser
1984 Ford LaserOP4w ago
I am not super familiar with Hono
jcheese
jcheese4w ago
either way thats not the problem i think. i have multiples of these and it works
1984 Ford Laser
1984 Ford LaserOP4w ago
Are you always passing a string for name? That's the only thing I can think to cause specific instances to have issues
jcheese
jcheese4w ago
yeah. const name = c.req.query('name'); its from query params also this endpoint is just to demonstrate that its broken websockets + etc doesnt work also in production
1984 Ford Laser
1984 Ford LaserOP4w ago
I just mean like sometimes gets other characters thrown in that maybe can't be serialized into a name ID? Have you tried writing a simple Durable Object before going down the Agents route?
jcheese
jcheese4w ago
ids are just something like smol-brains-5183 i have a full-blown ai app
1984 Ford Laser
1984 Ford LaserOP4w ago
What type is Env declared as here?
jcheese
jcheese4w ago
its auto-generated by cf

Did you find this page helpful?