Skip to content

Getting "Must call super constructor in derived class before accessing 'this' or returning from derived constructor" #1

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

Open
jcheese1 opened this issue Apr 21, 2025 · 0 comments

Comments

@jcheese1
Copy link

Repro:

  1. create fresh DO and workers project npm create cloudflare-latest

Paste from example:

import { DurableObject } from "cloudflare:workers";
import { Browsable } from "@outerbase/browsable-durable-object";

@Browsable()
export class MyDurableObject extends DurableObject<Env> {
	public sql: SqlStorage;

	constructor(ctx: DurableObjectState, env: Env) {
		super(ctx, env);
		this.sql = ctx.storage.sql;
	}

	async fetch(request: Request): Promise<Response> {
		return new Response("Hello from MyDurableObject");
	}
}

export default {
	async fetch(
		request: Request,
		env: Env,
		ctx: ExecutionContext,
	): Promise<Response> {
		const path = new URL(request.url).pathname;
		const id: DurableObjectId = env.MY_DURABLE_OBJECT.idFromName(path);
		const stub = env.MY_DURABLE_OBJECT.get(id);

		return stub.fetch(request);
	},
} satisfies ExportedHandler<Env>;
  1. run npm run start and access localhost
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