baselime/edge-logger

Logger context type error for Cloudflare RPC DurableObjects

Opened this issue · 0 comments

This library cannot be used without casting ctx as unknown as ExecutionContext or any while instantiate in latest DurableObject that extends DurableObject class:

export class TestServiceDurableObject extends DurableObject {
    private readonly logger: BaselimeLogger;

    public constructor(state: DurableObjectState, environment: Environment) {
        super(state, environment);

        this.logger = new BaselimeLogger({
            apiKey: environment[TestSecrets.baselimeApiKey],
            ctx: state,
            isLocalDev: environment.IS_LOCAL_DEV === "true",
            service: "test-service",
            namespace: "test-service-durable-object",
        });
    }

    public async sayHello(name: string): Promise<string> {
        return `Hello, ${name}!`;
    }
}

this is because DurableObjectState which is an execution context doesn't implement passThroughOnException(): void; from ExecutionContext. But I can see that you are using only waitUntil(promise: Promise<any>): void; from this type so this context type could be narrowed to use this library without type casting.