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

🐛 Bug: WorkerEntrypoint wrapped with Proxy throws error when invoked #2291

Open
rtbenfield opened this issue Jun 19, 2024 · 0 comments
Open

Comments

@rtbenfield
Copy link

A WorkerEntrypoint class implementation that is wrapped in a Proxy throws the following runtime error when the service binding is invoked. This was created in a Worker with a service binding to its own entrypoint for testing.

✘ [ERROR] workerd/io/worker.c++:1819: error: worker is not an actor but class name was requested; n = RpcEntrypoint

class RpcEntrypointImpl extends WorkerEntrypoint {
	myRpcCall() {
		return { ok: true }
	}
}
export const RpcEntrypoint = new Proxy(RpcEntrypointImpl, {})

// logs RpcEntrypoint__proto__ [Function: WorkerEntrypoint]
console.log('RpcEntrypoint__proto__', RpcEntrypoint.__proto__)

I found the error at the line below and attempted to trace how WorkerEntrypoint exports are determined. From what I understand, it should be detecting from __proto__, though in the JS side this seems to be retained by the proxy wrapper. This is my first time digging through the workerd code though so I could be off track.

LOG_ERROR_PERIODICALLY("worker is not an actor but class name was requested", n);

Why proxy a WorkerEntrypoint?

I'm attempting the Proxy wrapper as a way to apply OpenTelemetry instrumentation to a WorkerEntrypoint class. The proxy would extract the env form the constructor for configuration, wrap all RPC method invocations in spans, and export those spans automatically when the RPC method completes.

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