Vitest monorepo service bindings and "The RPC receiver does not implement the method"

I have a monorepo that looks something like this:
/packages/api/{my hono server with Services bindings}
/packages/services/
/packages/services/src/FooService
/packages/services/src/UsersService
/packages/api/{my hono server with Services bindings}
/packages/services/
/packages/services/src/FooService
/packages/services/src/UsersService
The API package has wrangler service bindings to the Services package.
// api/wrangler.jsonc
"services": [{
"binding": "FOO_SERVICE",
"service": "my-services",
"entrypoint": "FooService"
},
{
"binding": "USERS_SERVICE",
"service": "my-services",
"entrypoint": "UsersService"
}]
// api/wrangler.jsonc
"services": [{
"binding": "FOO_SERVICE",
"service": "my-services",
"entrypoint": "FooService"
},
{
"binding": "USERS_SERVICE",
"service": "my-services",
"entrypoint": "UsersService"
}]
I’m using Vite and Vitest for testing the API package with the following vitest config
// api/vitest.config.ts
export default defineWorkersProject(async () => {
return {
test: {
// … more setup
poolOptions: {
workers: {
wrangler: { configPath: `${__dirname}/wrangler.jsonc`, environment: 'test' },
singleWorker: true,
miniflare: {
bindings: {
TEST_MIGRATIONS: migrations,
TEST_SEED_FILES: seedFiles,
},
serviceBindings: {
USERS_SERVICE: { name: 'my-services', entrypoint: 'UsersService' },
FOO_SERVICE: { name: 'my-services', entryPoint: 'FooService' },
},
workers: [
{ // built by globalSetup.ts, coped into this directory
name: my-services',
modules: true,
scriptPath: './.test/workers/services/my_services/index.js',
compatibilityDate: '2025-01-01',
compatibilityFlags: ['nodejs_compat'],
},
],
},
},
},
},
};
});
// api/vitest.config.ts
export default defineWorkersProject(async () => {
return {
test: {
// … more setup
poolOptions: {
workers: {
wrangler: { configPath: `${__dirname}/wrangler.jsonc`, environment: 'test' },
singleWorker: true,
miniflare: {
bindings: {
TEST_MIGRATIONS: migrations,
TEST_SEED_FILES: seedFiles,
},
serviceBindings: {
USERS_SERVICE: { name: 'my-services', entrypoint: 'UsersService' },
FOO_SERVICE: { name: 'my-services', entryPoint: 'FooService' },
},
workers: [
{ // built by globalSetup.ts, coped into this directory
name: my-services',
modules: true,
scriptPath: './.test/workers/services/my_services/index.js',
compatibilityDate: '2025-01-01',
compatibilityFlags: ['nodejs_compat'],
},
],
},
},
},
},
};
});
With this setup I currently get an error of the following shape TypeError: The RPC receiver does not implement the method "getFoo". when calling c.env.FOO_SERVICE.getFoo(). What’s the right way to tackle this?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?