Skip to content
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

lz4 module causes Azure Function App to fail #275

Open
cdavaz opened this issue Feb 1, 2025 · 0 comments
Open

lz4 module causes Azure Function App to fail #275

cdavaz opened this issue Feb 1, 2025 · 0 comments

Comments

@cdavaz
Copy link

cdavaz commented Feb 1, 2025

I know others have reported issues with the lz4 module as well. In my case, it's only an issue when I deploy my app as an Azure Function.

Result: Failure Exception: Worker was unable to load function clinical: 'Module did not self-register: '/home/site/wwwroot/node_modules/lz4/build/Release/xxhash.node'.' Stack: Error: Worker was unable to load function clinical: 'Module did not self-register: '/home/site/wwwroot/node_modules/lz4/build/Release/xxhash.node'.' at Module._extensions..node (node:internal/modules/cjs/loader:1460:18) at Module.load (node:internal/modules/cjs/loader:1203:32) at Module._load (node:internal/modules/cjs/loader:1019:12) at Module.require (node:internal/modules/cjs/loader:1231:19) at Object.apply (/azure-functions-host/workers/node/dist/src/worker-bundle.js:2:51713) at Module.patchedRequire (/home/site/wwwroot/node_modules/diagnostic-channel/dist/src/patchRequire.js:16:46) at Module.patchedRequire (/home/site/wwwroot/node_modules/require-in-the-middle/index.js:246:27) at Hook._require.Module.require (/home/site/wwwroot/node_modules/require-in-the-middle/index.js:171:27) at require (node:internal/modules/helpers:177:18) at Object.<anonymous> (/home/site/wwwroot/node_modules/lz4/lib/utils.js:4:11)

Basically the failure is "Module did not self-register", which I guess this code misses in the exception handler:

import type LZ4Namespace from 'lz4';
type LZ4Module = typeof LZ4Namespace;
function tryLoadLZ4Module(): LZ4Module | undefined {
try {
return require('lz4'); // eslint-disable-line global-require
} catch (err) {
const isModuleNotFoundError = err instanceof Error && 'code' in err && err.code === 'MODULE_NOT_FOUND';
if (!isModuleNotFoundError) {
throw err;
}
}
}
export default tryLoadLZ4Module();

I was able to work around this by removing the lz4 optional dependency and lz4 entry manually from my package-lock.json file, which of course is not ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant