fix: DDP method calls returning 404 for void methods
Proposed changes (including videos or screenshots)
This PR fixes an issue in the DDP method call handling within the ddp-streamer where valid method calls could incorrectly return a 404 method not found response.
Root cause
The issue was caused by incorrect method resolution in the DDP execution flow within the ddp-streamer. Since the ddp-streamer module is only active in Enterprise environments with microservice deployment, the issue was isolated to this setup.
In Server.ts of ddp-streamer, the call() method used a truthiness check on the return value of MeteorService.callMethodWithToken :
// BUG: treats void/undefined/null/0/false/"" as "method not found"
if (result?.result) {
return this.result(client, packet, result.result);
}
throw new MeteorError(404, `Method '${packet.method}' not found`);
A method returns void → result.result is undefined → falsy → false 404 thrown. The method could have been executed successfully, but the client received an error.
This mismatch between execution and resolution led to false-negative error responses being propagated to clients.
Fix
Always return result?.result to the client. If the method truly doesn't exist, Meteor.callAsync inside callMethodWithToken throws its own error, caught by the outer catch block.
Issue(s)
Steps to test or reproduce
Further comments
Summary by CodeRabbit
-
Bug Fixes
- Prevented incorrect 404 responses for certain DDP method calls so successful executions no longer surface as not-found errors.
-
Tests
- Added unit tests covering method delegation, local method handling, error propagation, and closed-client behavior.
-
Chores
- Introduced test configuration, enabled Jest-based test scripts, updated TypeScript test types, and added a changeset for a patch release.