Skip to content
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

Logger context type error for Cloudflare RPC DurableObjects #9

Open
Futhark opened this issue May 3, 2024 · 0 comments
Open

Logger context type error for Cloudflare RPC DurableObjects #9

Futhark opened this issue May 3, 2024 · 0 comments

Comments

@Futhark
Copy link

Futhark commented May 3, 2024

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.

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

No branches or pull requests

1 participant