You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the typed client (thus this is browser error) I get the following error:
500
Can not apply hooks. 'report' is not a function
at objectHooks (.../app/node_modules/.pnpm/@feathersjs+hooks@0.9.0/node_modules/@feathersjs/hooks/script/hooks.js:66:19)
Report is a custom function of the users service: async report(data: ReportData, params: ServiceParams)
I also call some hooks on the custom method, i.e.:
I didn't get this when I used Feathers 5.0.24, so the only thing that changed is that I updated the Feathers API and client to 5.0.33.
The only relevant change I saw in the releases was that the typing for the service methods had changed, so I changed it to: export const userMethods: Array<keyof UserService> = ['find', 'get', 'create', 'patch', 'remove', 'report']
That made no difference however, I still get the error.
I've had to remove all custom methods from <service>Methods exports in all *.shared.ts files, all custom methods cause this error if they are included in the exposed methods array.
Calling the custom methods in the server or via Postman directly is not an issue, it works as expected.
So it's an issue with the Feathers client only.
@daffl / @marshallswain any ideas?
I've checked the return values of api.service() in the client, and it contains the custom methods so it's not like they are not included in the client.
If I remove 'test' from userMethods, build the client and install the client, then there are no errors, it's only when it's added to the userMethods, which of course it must be to be available in the client.
Then built the client using: pnpm bundle:client
Installed the client in my app: pnpm add http://localhost:3030/test-0.0.1.tgz
I don't have any hooks defined for the custom service method (not in the API nor the client app).
In client I then get this error:
500
Can not apply hooks. 'test' is not a function...
at objectHooks (E:/Specs/Development/Athlytic/app/node_modules/.pnpm/@feathersjs+hooks@0.9.0/node_modules/@feathersjs/hooks/script/hooks.js:66:19)
at hooks (E:/Specs/Development/Athlytic/app/node_modules/.pnpm/@feathersjs+hooks@0.9.0/node_modules/@feathersjs/hooks/script/index.js:54:43)
at Feathers.hookMixin (E:/Specs/Development/Athlytic/app/node_modules/.pnpm/@feathersjs+feathers@5.0.34/node_modules/@feathersjs/feathers/src/hooks.ts:212:8)
at (E:/Specs/Development/Athlytic/app/node_modules/.pnpm/@feathersjs+feathers@5.0.34/node_modules/@feathersjs/feathers/src/application.ts:178:36)
at Feathers.use (E:/Specs/Development/Athlytic/app/node_modules/.pnpm/@feathersjs+feathers@5.0.34/node_modules/@feathersjs/feathers/src/application.ts:178:17)
at Feathers.userClient (E:/Specs/Development/Athlytic/app/node_modules/.pnpm/athlytic-api@http+++localhost+3030+test-0.0.1.tgz_typescript@5.8.3/node_modules/test/lib/services/users/users.shared.js:8:12)
at Feathers.configure (E:/Specs/Development/Athlytic/app/node_modules/.pnpm/@feathersjs+feathers@5.0.34/node_modules/@feathersjs/feathers/src/application.ts:52:14)
at createClient (E:/Specs/Development/Athlytic/app/node_modules/.pnpm/athlytic-api@http+++localhost+3030+test-0.0.1.tgz_typescript@5.8.3/node_modules/test/lib/client.js:24:12)
at E:/Specs/Development/Athlytic/app/plugins/01.feathers.ts:21:64)
In the client plugin I'm just creating the Feathers client:
Activity
EmileSpecs commentedon May 12, 2025
Some more details:
<service>Methodsexports in all*.shared.tsfiles, all custom methods cause this error if they are included in the exposed methods array.So it's an issue with the Feathers client only.
@daffl / @marshallswain any ideas?
I've checked the return values of
api.service()in the client, and it contains the custom methods so it's not like they are not included in the client.daffl commentedon May 12, 2025
Thanks for digging into that. I'm assuming this would be reproducible by adding a custom method to a client service and trying to add hooks to it?
EmileSpecs commentedon May 13, 2025
Hi @daffl
I just created a totally new install using:
pnpm create feathers@latest testI also added authentication using:
npx feathers generate authenticationI then ONLY added this to the users.class.ts:
users.shared.ts then has
userMethods:If I remove
'test'fromuserMethods, build the client and install the client, then there are no errors, it's only when it's added to theuserMethods, which of course it must be to be available in the client.Then built the client using:
pnpm bundle:clientInstalled the client in my app:
pnpm add http://localhost:3030/test-0.0.1.tgzI don't have any hooks defined for the custom service method (not in the API nor the client app).
In client I then get this error:
In the client plugin I'm just creating the Feathers client:
EmileSpecs commentedon May 22, 2025
Hi @daffl
I have found an interesting clue:
Note that the
changemethod does exist in theSubscriptionServiceclass.In my client, I have this to create the connection:
When creating a REST connection, I get the error but when I create a socket connection I do not get the error.
So it seems to me that this only happens when using REST.
Hope that helps narrow things down.
daffl commentedon May 22, 2025
Would this be enough to create a minimal example to reproduce? I wonder if this is happening because of how custom methods are initialised in https://github.com/feathersjs/feathers/blob/dove/packages/rest-client/src/base.ts#L70-L96
laurensiusadi commentedon Jan 14, 2026
https://github.com/feathersjs/feathers/blob/dove/packages/feathers/src/service.ts#L30-L36
Adding
methods.filterseems to fix it locally for me.daffl commentedon Jan 14, 2026
@laurensiusadi That looks like a reasonable change. Want to submit a PR?
daffl commentedon Jan 14, 2026
Actually, now I'm wondering why it doesn't just throw an error if you are trying to make a method public that doesn't exist on the service.
laurensiusadi commentedon Jan 20, 2026
I have opened a PR for this @daffl