fedify icon indicating copy to clipboard operation
fedify copied to clipboard

Schema loading limitation in Cloudflare Workers affects test coverage

Open dahlia opened this issue 6 months ago • 2 comments

The vocabulary test suite currently has reduced functionality when running on Cloudflare Workers due to platform limitations. Specifically, the test file fedify/vocab/vocab.test.ts contains logic that prevents schema files from being loaded in the Cloudflare Workers environment because this platform does not support asynchronous I/O operations within the global scope.

Currently, when running on Cloudflare Workers, the schema loading code defaults to an empty collection, which causes certain tests to be skipped entirely. This limitation is documented in the code with a FIXME comment that explicitly notes the Cloudflare Workers restriction:

https://github.com/fedify-dev/fedify/blob/77c62d3ec6e1b6632a6997cf367e1a56e2941a41/fedify/vocab/vocab.test.ts#L860-L863

The root issue stems from the fact that the test suite attempts to load YAML schema files using loadSchemaFiles() during module initialization. While this works in Deno and Node.js environments, Cloudflare Workers prohibits such operations at the global level, requiring all asynchronous I/O to occur within request handlers or other appropriate contexts.

A potential solution would involve implementing a code generation step that transforms the YAML schema files into JavaScript or JSON modules that can be imported dynamically. Since Cloudflare Workers does support dynamic imports of static modules, this approach would allow the test suite to access the schema data without performing file system operations. The generated modules could be created during the existing code generation phase and committed to the repository alongside the current vocabulary type definitions.

This enhancement would ensure complete test coverage across all supported runtime environments and eliminate the current disparity in test execution between platforms. The change would also maintain the existing development workflow while extending compatibility to the Cloudflare Workers platform.

dahlia avatar May 30 '25 08:05 dahlia

@dahlia This issue has been assigned for over two weeks without updates. Please provide a status update, or unassign yourself if you're unable to continue working on it.

github-actions[bot] avatar Oct 09 '25 09:10 github-actions[bot]

@dahlia This issue has been assigned for over two weeks without updates. Please provide a status update, or unassign yourself if you're unable to continue working on it.

github-actions[bot] avatar Oct 24 '25 01:10 github-actions[bot]