Skip to content

"Cannot find module '/var/task/thread.js'" in AWS Lambda #15

@tonisives

Description

@tonisives

Weird error happens in AWS Lambda environment only. It works locally.

I am using solidity-code-metrics in my project. If I include the const surya = require('surya');, then the lambda fails with this uncaught exception. It isn’t even caught my try {} catch block. So this isn’t a normal crash

If I remove the surya import, then the the lambda manages to finish.

https://github.com/tonisives/solidity-metrics/blob/master/src/metrics/metrics.js#L17

Error with surya import enabled

2024-01-18T07:26:34 2024-01-18T07:26:34.870Z    346d3c3a-3183-44b4-ad82-2d4b0b6b96bf    INFO    metrics 35. Storing metrics                                   
2024-01-18T07:26:35 2024-01-18T07:26:35.151Z    346d3c3a-3183-44b4-ad82-2d4b0b6b96bf    ERROR   Uncaught Exception      {"errorType":"Error",
"errorMessage":"Cannot find module '/var/task/thread.js'",
"code":"MODULE_NOT_FOUND",
"requireStack":[],
"stack":
["Error: Cannot find module '/var/task/thread.js'","    
   at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)","   
   at Module._load (node:internal/modules/cjs/loader:985:27)","    
   at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)"," 
   at MessagePort.<anonymous> (node:internal/main/worker_thread:185:26)","    
   at [nodejs.internal.kHybridDispatch] (node:internal/event_target:814:20)","   
   at exports.emitMessage (node:internal/per_context/messageport:23:28)"]}
2024-01-18T07:26:35 Unknown application error occurred
Runtime.Unknown                                                                                                                                               
2024-01-18T07:26:35 END RequestId: 346d3c3a-3183-44b4-ad82-2d4b0b6b96bf

Please note I have made some patches to get SCM working in Lambda. But this one seems to be a new one from changes from max 1 year ago.

I tried surya 0.4.6 and also an update to 0.4.11

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