Murder Chicken
Murder Chicken
CDCloudflare Developers
Created by Silvan on 4/28/2025 in #workers-help
An RPC stub was not disposed properly using meta frameworks
Usually when I was making a buttload of RPC calls in a short period of time.
29 replies
CDCloudflare Developers
Created by Silvan on 4/28/2025 in #workers-help
An RPC stub was not disposed properly using meta frameworks
I noticed it was inconsistent as well.
29 replies
CDCloudflare Developers
Created by Silvan on 4/28/2025 in #workers-help
An RPC stub was not disposed properly using meta frameworks
That's awesome. I hated wrapping method calls to bypass the issue.
29 replies
CDCloudflare Developers
Created by Silvan on 4/28/2025 in #workers-help
An RPC stub was not disposed properly using meta frameworks
I also have limited DO experience so, my examples might not be 1:1.
29 replies
CDCloudflare Developers
Created by Silvan on 4/28/2025 in #workers-help
An RPC stub was not disposed properly using meta frameworks
I hadn't seen that update.
29 replies
CDCloudflare Developers
Created by Silvan on 4/28/2025 in #workers-help
An RPC stub was not disposed properly using meta frameworks
AFAIK
29 replies
CDCloudflare Developers
Created by Silvan on 4/28/2025 in #workers-help
An RPC stub was not disposed properly using meta frameworks
Not unless I use the experimental worker.
29 replies
CDCloudflare Developers
Created by Silvan on 4/28/2025 in #workers-help
An RPC stub was not disposed properly using meta frameworks
This would be a minimal example worker-to-service worker.
29 replies
CDCloudflare Developers
Created by Silvan on 4/28/2025 in #workers-help
An RPC stub was not disposed properly using meta frameworks
Service Worker
export default {
async fetch(request, env, ctx) {
// ... stuff
},
};

export class ServiceLayerEntryPoint extends WorkerEntrypoint {
async getKvValue(key: string) {
return await this.env.KV.get(key);
}
}
export default {
async fetch(request, env, ctx) {
// ... stuff
},
};

export class ServiceLayerEntryPoint extends WorkerEntrypoint {
async getKvValue(key: string) {
return await this.env.KV.get(key);
}
}
Consumer Worker
export default {
async fetch(request, env, ctx) {
const kvKey = 'somevalue';
const kvValueFromService = await executeRpcWithCleanup(() => env.SERVICE.getKvValue(kvKey));
},
};
export default {
async fetch(request, env, ctx) {
const kvKey = 'somevalue';
const kvValueFromService = await executeRpcWithCleanup(() => env.SERVICE.getKvValue(kvKey));
},
};
29 replies
CDCloudflare Developers
Created by Silvan on 4/28/2025 in #workers-help
An RPC stub was not disposed properly using meta frameworks
You're using a WorkerEntrypoint? The methods are async?
29 replies
CDCloudflare Developers
Created by Silvan on 4/28/2025 in #workers-help
An RPC stub was not disposed properly using meta frameworks
How are you implementing it?
29 replies
CDCloudflare Developers
Created by Silvan on 4/28/2025 in #workers-help
An RPC stub was not disposed properly using meta frameworks
What's your RPC method look like?
29 replies
CDCloudflare Developers
Created by Silvan on 4/28/2025 in #workers-help
An RPC stub was not disposed properly using meta frameworks
I had encountered this as well and was able to fix it through use of a helper function on the consumer side (i.e., when I make the RPC request).
/**
* Executes an RPC call and ensures proper cleanup.
* @param {Function} rpcCall - A function that performs the RPC call.
* @returns {Promise<any>} - The result of the RPC call.
*/
export async function executeRpcWithCleanup(rpcCall) {
let rpcResult = null;
try {
rpcResult = await rpcCall();
return rpcResult;
} finally {
if (rpcResult && typeof rpcResult[Symbol.dispose] === 'function') {
// console.info('Disposing RPC result');
rpcResult[Symbol.dispose]();
} else {
// console.info('No Symbol.dispose method on rpcResult');
}
}
}
/**
* Executes an RPC call and ensures proper cleanup.
* @param {Function} rpcCall - A function that performs the RPC call.
* @returns {Promise<any>} - The result of the RPC call.
*/
export async function executeRpcWithCleanup(rpcCall) {
let rpcResult = null;
try {
rpcResult = await rpcCall();
return rpcResult;
} finally {
if (rpcResult && typeof rpcResult[Symbol.dispose] === 'function') {
// console.info('Disposing RPC result');
rpcResult[Symbol.dispose]();
} else {
// console.info('No Symbol.dispose method on rpcResult');
}
}
}
await executeRpcWithCleanup(() => env.SERVICE.myFunction());
await executeRpcWithCleanup(() => env.SERVICE.myFunction());
Your mileage may vary but hopefully this works for you.
29 replies
CDCloudflare Developers
Created by Murder Chicken on 3/14/2025 in #workflows
If I try and use cross-script calls like
Possibly. They've made multi-worker through wrangler a bit more intuitive recently (showing connection status, etc) but multi-worker local start order has always been super-confusing.
23 replies
CDCloudflare Developers
Created by Murder Chicken on 3/14/2025 in #workflows
If I try and use cross-script calls like
Multi-worker support has been slow to improve. These edge-cases should be fixed soon, I'm guessing.
23 replies
CDCloudflare Developers
Created by Murder Chicken on 3/14/2025 in #workflows
If I try and use cross-script calls like
I should probably report this as a bug though... it does not seem to be intended behavior. You should be able to start these up individually, like usual.
23 replies
CDCloudflare Developers
Created by Murder Chicken on 3/14/2025 in #workflows
If I try and use cross-script calls like
It's the order of worker invocation in the wrangler command.
23 replies
CDCloudflare Developers
Created by Murder Chicken on 3/14/2025 in #workflows
If I try and use cross-script calls like
Ok, that did work (for real this time)
23 replies
CDCloudflare Developers
Created by Murder Chicken on 3/14/2025 in #workflows
If I try and use cross-script calls like
Let me try a few orders of the workers.
23 replies
CDCloudflare Developers
Created by Murder Chicken on 3/14/2025 in #workflows
If I try and use cross-script calls like
Gave the illusion it was working.
23 replies