AWS Lambda、节点、adm-zip:系统调用参数中的错误地址

AWS Lambda, node, adm-zip: bad address in system call argument

可以使用 AWS Lambda 创建和读取 /tmp/temp.zip 但此行会导致错误:

var zip = new AdmZip("/tmp/temp.zip"); // https://www.npmjs.com/package/adm-zip

错误是什么意思?

2018-08-08T13:23:41.074Z    2c1d866d-9b0e-11e8-8f32-8b0d6b822525    Error: EFAULT: bad address in system call argument, read
    at Object.fs.readSync (fs.js:675:18)
    at tryReadSync (fs.js:540:20)
    at Object.fs.readFileSync (fs.js:575:19)
    at new module.exports (/var/task/node_modules/adm-zip/zipFile.js:17:17)
    at new module.exports (/var/task/node_modules/adm-zip/adm-zip.js:20:11)
    at PassThrough.readStream.on (/var/task/index.js:28:19)
    at emitNone (events.js:111:20)
    at PassThrough.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
END RequestId: 2c1d866d-9b0e-11e8-8f32-8b0d6b822525
REPORT RequestId: 2c1d866d-9b0e-11e8-8f32-8b0d6b822525  Duration: 39773.72 ms   Billed Duration: 39800 ms   Memory Size: 128 MB Max Memory Used: 128 MB 
RequestId: 2c1d866d-9b0e-11e8-8f32-8b0d6b822525 Process exited before completing request

线索:

Memory Size: 128 MB Max Memory Used: 128 MB

所以 lambda 运行 内存不足。给它 1024 MB 解决了问题。