-
Notifications
You must be signed in to change notification settings - Fork 0
Support Cloudflare Workers #47
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
base: main
Are you sure you want to change the base?
Conversation
|
Claude finished @mickmister's task —— View job Code Review CompleteI've thoroughly reviewed this PR that adds Cloudflare Workers support. Here's my comprehensive feedback: Review Checklist:
🔍 Code Quality & ArchitectureStrengths:
Areas for Improvement:
🐛 Potential Bugs & Issues
🔒 Security Concerns
⚡ Performance Considerations
🧪 Test CoverageMajor Gap: No tests found for CF Workers implementation
📋 Configuration Issues
🎯 RecommendationsHigh Priority:
Medium Priority:
Low Priority:
💡 Suggested FixesFor the WebSocket race condition: const createBroadcastMessage = () => {
let wsInstance: ReturnType<typeof crosswsCf> | null = null;
return {
broadcastMessage: (message: string) => {
if (!wsInstance) {
console.warn('WebSocket not initialized, message dropped');
return;
}
return wsInstance.publish('event', message);
},
setWs: (ws: ReturnType<typeof crosswsCf>) => {
wsInstance = ws;
}
};
};Overall Assessment: This is a solid foundation for CF Workers support, but needs attention to the race condition and testing before merge. |
Deploying jamtools-docs-new with
|
| Latest commit: |
52f19fa
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4c2d9810.jamtools-docs-new.pages.dev |
| Branch Preview URL: | https://refactor-springboard-server.jamtools-docs-new.pages.dev |
… with initialization timing
|
🚀 Cloudflare Workers deployment validation completed! Deployment URL: The build completed successfully and would deploy to the above URL if this were merged to main. |
|
🚀 Cloudflare Workers deployment validation completed! Deployment URL: The build completed successfully and would deploy to the above URL if this were merged to main. |
|
Planning to merge with the intention of soon adding more robust if-defs for conditionally compiling based on platform/context https://jam.tools/docs/springboard/conditional-compilation |
|
@claude Please review this PR |
|
Claude finished @mickmister's task —— View job PR Review: Cloudflare Workers SupportReviewed this PR that adds Cloudflare Workers support to the jamtools platform. Review Progress:
🎉 Improvements Since Last ReviewFixed Issues:
🐛 Critical Issues Found1. Variable Used Before Declaration (High Priority)File: const rpc = new ServerJsonRpcClientAndServer({
broadcastMessage: (message) => {
return rpcService.broadcastMessage(message); // ❌ rpcService used before declaration
},
});
const rpcService = new SharedJsonRpcServer({ // ❌ Declared after usage
processRequest: async (message, middlewareResult: unknown) => {
return rpc!.processRequest(message, middlewareResult);
},
rpcMiddlewares,
}, coreDeps.room);Impact: This will cause runtime errors due to 🔍 Architecture & Code QualityStrengths:
Areas for Improvement:
🧪 Test Coverage GapMajor Gap: No tests found for CF Workers implementation
🔒 Security & PerformanceSecurity Observations:
Performance:
🚀 Deployment & CIGitHub Workflow (
|
mickmister
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@claude Please adress feedback
| initialize = async () => { | ||
| const registeredMacroCallbacks = (macroTypeRegistry.registerMacroType as unknown as {calls: CapturedRegisterMacroTypeCall[]}).calls || []; | ||
| macroTypeRegistry.registerMacroType = this.registerMacroType; | ||
| // macroTypeRegistry.registerMacroType = this.registerMacroType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented code. Pretty sure this wasn't useful in the first place
| import {esbuildPluginCfWorkersConfig} from './esbuild_plugins/esbuild_plugin_cf_workers_config'; | ||
|
|
||
| export type SpringboardPlatform = 'all' | 'main' | 'mobile' | 'desktop' | 'browser_offline' | 'partykit'; | ||
| export type SpringboardPlatform = 'all' | 'main' | 'mobile' | 'desktop' | 'browser_offline' | 'partyserver' | 'cf-workers'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove partyserver and references to it in this file
| ...platformBrowserBuildConfig.esbuildPlugins?.(args) || [], | ||
| { | ||
| name: 'move-html', | ||
| setup(build) { | ||
| build.onEnd(async () => { | ||
| const htmlFilePath = `${args.outDir}/index.html`; | ||
| const newHtmlFilePath = `${args.outDir}/../index.html`; | ||
|
|
||
| await fs.promises.rename(htmlFilePath, newHtmlFilePath); | ||
| }); | ||
| }, | ||
| }, | ||
| ], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Springboard dist folder structure should be:
dist/node/server/dist
dist/node/browser/dist
dist/cf-workers/server/dist
dist/cf-workers/browser/dist
|
|
||
| const allImports = `import initApp from '${coreFile}'; | ||
| import '${applicationEntrypoint}'; | ||
| export * from '${coreFile}'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed for durable object export
| } | ||
|
|
||
| const partykitHost = `${location.origin}/parties/main/myroom`; | ||
| const partykitHost = `${location.origin}/parties/my-server/myroom`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow up task after this PR to support lobby and rooms out of the box
| import path from 'node:path'; | ||
|
|
||
| import {serve} from '@hono/node-server'; | ||
| import crosswsNode, {NodeAdapter} from 'crossws/adapters/node'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unused import
|
|
||
| constructor (private url: string, private rpcProtocol: 'http' | 'websocket' = 'http') { | ||
| // @ts-ignore import.meta.env usage | ||
| const shouldChangeToWs = import.meta.env.PUBLIC_USE_WEBSOCKETS_FOR_RPC === 'true'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import.meta.env or process.env?
| import {NodeKVStoreService} from '@springboardjs/platforms-node/services/node_kvstore_service'; | ||
| import {NodeLocalJsonRpcClientAndServer} from '@springboardjs/platforms-node/services/node_local_json_rpc'; | ||
| import {ServerAppDependencies} from './types/server_app_dependencies'; | ||
| // import {KVStoreFromKysely} from '@springboardjs/data-storage/kv_api_kysely'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove dead/commented code
| const service: NodeJsonRpcServer = new NodeJsonRpcServer({ | ||
| processRequest: async (message) => { | ||
| return rpc!.processRequest(message); | ||
| // const service: CrossWsJsonRpcServer = new CrossWsJsonRpcServer({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More comments
| // TODO: is this actually necessary to have here? | ||
| app.get('/ws', (c) => { | ||
| // This route is a placeholder - crossws adapter handles the actual upgrade | ||
| return c.text('WebSocket endpoint', 426); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove this if it's not needed
|
Claude finished @mickmister's task —— View job Review Feedback Addressed ✅Successfully addressed all 11 review comments: Todo List:
Changes Made:
Validation Results:
Follow-up Task Noted:The comment on All review feedback has been successfully addressed and changes have been committed to the branch. |
- Remove commented code from macro_module.tsx - Remove partyserver references from SpringboardPlatform type - Update dist folder structure to use platform-family/context pattern - Clean up commented code in cf-workers entrypoints and services - Remove unused NodeAdapter import from node_entrypoint.ts - Change import.meta.env to process.env in browser_json_rpc.ts for consistency - Remove dead/commented code from hono_app.ts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Michael Kochell <mickmister@users.noreply.github.com>
No description provided.