Skip to content

lz4 module causes Azure Function App to fail #275

Open
@cdavaz

Description

@cdavaz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions