fastify-secure-session icon indicating copy to clipboard operation
fastify-secure-session copied to clipboard

ERR_DLOPEN_FAILED for Sodium native

Open Pfeifenjoy opened this issue 1 year ago • 6 comments

Prerequisites

  • [x] I have written a descriptive issue title
  • [x] I have searched existing issues to ensure the bug has not already been reported

Fastify version

5.2.1

Plugin version

8.1.0

Node.js version

22.13.1

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

arch

Description

While importing the @fastify/secure-session plugin I get the following error:

Welcome to Node.js v22.13.1.                                                                                                                                                                  
Type ".help" for more information.                                                                                                                                                            
> require("@fastify/secure-session")                                                                                                                                                          
Uncaught:                                                                                                                                                                                     
Error: /home/<path to project>/node_modules/sodium-native/prebuilds/linux-x64/sodium-native.node: cannot enable executable stack as shared object requires: Invalid argument  
    at Object..node (node:internal/modules/cjs/loader:1725:18)                                                                                                                                
    at Module.load (node:internal/modules/cjs/loader:1313:32)                                                                                                                                 
    at Function._load (node:internal/modules/cjs/loader:1123:12)                                                                                                                              
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)                                                                                                                             
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)                                                                                                                               
    at Module.require (node:internal/modules/cjs/loader:1335:12)                                                                                                                              
    at require (node:internal/modules/helpers:136:16)                                                                                                                                         
    at load (/home/<path to project>/node_modules/node-gyp-build/node-gyp-build.js:22:10)                                                                                     
    at Object.<anonymous> (/home/<path to project>/node_modules/sodium-native/index.js:1:43) {                                                                                
  code: 'ERR_DLOPEN_FAILED'                                                                                                                                                                   
}

I guess this is a sodium-native bug but this package is required by @fastify/secure-session.

Link to code that reproduces the bug


Expected Behavior

No response

Pfeifenjoy avatar Feb 04 '25 10:02 Pfeifenjoy

Migh be related to https://github.com/holepunchto/sodium-native/issues/202.

mcollina avatar Feb 05 '25 07:02 mcollina

Can you verify if https://github.com/fastify/fastify-secure-session/pull/247 fixes it?

mcollina avatar Feb 05 '25 07:02 mcollina

Thanks the PR solves it.

As a temporary fix I use this https://github.com/fastify/fastify-secure-session/pull/247#pullrequestreview-2460749477

Note that the PR is not merged it still uses the broken version: https://github.com/fastify/fastify-secure-session/blob/main/package.json#L77

Not sure how you want to deal with it, from my side I am ok with the work around of overwriting.

TBH I would not leave it though at the current expression ^4.0.10. Either it should be fixed for the lower version as in the PR or if there is a newer version that fixes it I would upgrade the dependency to be greater or equal to that version.

Pfeifenjoy avatar Feb 06 '25 21:02 Pfeifenjoy

I don't have a good solution atm. I think we would need to deprecate this module altogether and drop from the recommendations as sodium-native is not reliable long term.

mcollina avatar Mar 27 '25 16:03 mcollina

This caused me headaches... Maybe this thread brings some answers, so sodium-native becomes usable again: https://github.com/jedisct1/libsodium/discussions/1449

dennemark avatar Apr 17 '25 12:04 dennemark

I just ran into that too... Could someone describe exactly how to fix the problem? I read through the various issues but couldn't figure it out.

When I set the version to 4.2.0, it works for amd64 builds but no longer for arm builds. If I set the version to 4.3.3, the arm build works, but then linux/amd64 no longer works.

PS: I create multi-arch builds with docker buildx.

Edit (sleeping does wonders): using now 4.2.0 - looks like i forgot to add gcompat in the runtime image...

andreas-soroko avatar Sep 15 '25 14:09 andreas-soroko