-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix the need to await getServerByName #26
Comments
related cloudflare/workerd#2246 |
this is now not as slow as it was, even tho it's async, which is good |
@threepointone stupid idea i'm sure you've already considered: why not just include the name in every request (e.g. via a header like you're currently doing), and only initialize it if it's missing? seems a lot less finicky than needing to ensure a specific fetch request/RPC is made once but definitely before any subsequent requests. this is what we do and it works fine for us — actually, for us, we just use the DO worker as a complete pass-thru to the DO itself, so the DO can pull its own name directly out of the request URL. here's our entire DO worker.ts: import { getSantizedRoomIdFromGameServerUrl } from '@common/getSantizedRoomIdFromRequest';
const worker: ExportedHandler<Environment> = {
async fetch(request, env) {
const roomId = getSantizedRoomIdFromGameServerUrl(request.url);
if (!roomId) {
return new Response(`Nothing to see here. Move along.`, {
status: 200,
});
}
const durableObjectId = env.ROOM_DURABLE_OBJECT.idFromName(roomId);
const durableObjectStub = env.ROOM_DURABLE_OBJECT.get(durableObjectId);
try {
return await durableObjectStub.fetch(request);
} catch (error) {
console.error('Failed to fetch from durable object', error);
return new Response(`Something went wrong: ${error}`, {
status: 500,
});
}
},
};
export { RoomDurableObject } from './RoomDurableObject';
export default worker; In the meantime... I eagerly await cloudflare/workerd#2240 being fixed :D |
This might be a bug in workerd, must follow up
https://github.com/threepointone/partyflare/blob/69c6c859223f7e419ac0b7a5f14331e44eeeb009/packages/partyflare/src/index.ts#L53-L57
The text was updated successfully, but these errors were encountered: