Closed shamoons closed 5 years ago
Very strange indeed. I tried running this directly on the lamba and it worked:
const key = process.env.ENVKEY
var ext = "",
filePath = path.join(__dirname, "node_modules", "envkey", "ext", ["envkey-fetch", ENVKEY_FETCH_VERSION, platformPart, 'amd64'].join("_"), ("envkey-fetch" + ext)),
execArgs = [key, "--client-name", "envkey-node", "--client-version", "1.2.6"]
var resp = execFileSync(filePath, execArgs).toString()
So I'm not sure what the error is
cc @danenania
Hmm, definitely strange—looking into this.
On Wed, Aug 14, 2019 at 5:51 PM Shamoon Siddiqui notifications@github.com wrote:
cc @danenania https://github.com/danenania
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/envkey/envkey-node/issues/18?email_source=notifications&email_token=AAEFERUR5R6ATKWZF7XUMWLQESSARA5CNFSM4ILZOT52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4KQVOY#issuecomment-521472699, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEFERT66CBYCSYUJY774H3QESSARANCNFSM4ILZOT5Q .
It looks like error is not being handled and display properly... e.stderr
is null in console.error(e.stderr.toString())
I'm pushing a fix for that right now so that we can see what the underlying error is.
Ok, 1.2.7 is now released with the error handling fixed. Can you post the error message with the new version when you get a chance?
Logs are better, but still error:
START RequestId: 0e0f9e4f-fc9c-4365-8556-3e909d4e8699 Version: $LATEST
2019-08-15T12:04:04.970Z undefined ERROR Error: spawnSync /var/task/node_modules/envkey/ext/envkey-fetch_1.2.5_linux_amd64/envkey-fetch ENOENT
at Object.spawnSync (internal/child_process.js:1002:20)
at spawnSync (child_process.js:614:24)
at execFileSync (child_process.js:642:13)
at fetch (/var/task/node_modules/envkey/loader.js:201:17)
at Object.load (/var/task/node_modules/envkey/loader.js:91:29)
at Object.<anonymous> (/var/task/node_modules/envkey/index.js:1:41)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-08-15T12:04:04.974Z undefined ERROR { Error: spawnSync /var/task/node_modules/envkey/ext/envkey-fetch_1.2.5_linux_amd64/envkey-fetch ENOENT
at Object.spawnSync (internal/child_process.js:1002:20)
at spawnSync (child_process.js:614:24)
at execFileSync (child_process.js:642:13)
at fetch (/var/task/node_modules/envkey/loader.js:201:17)
at Object.load (/var/task/node_modules/envkey/loader.js:91:29)
at Object.<anonymous> (/var/task/node_modules/envkey/index.js:1:41)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
errno: 'ENOENT',
code: 'ENOENT',
syscall:
'spawnSync /var/task/node_modules/envkey/ext/envkey-fetch_1.2.5_linux_amd64/envkey-fetch',
path:
'/var/task/node_modules/envkey/ext/envkey-fetch_1.2.5_linux_amd64/envkey-fetch',
spawnargs:
[ 'aAgSa12RWyGRsgENG7HF-5PQoFtZC2sZnw5WJ',
'',
'--client-name',
'envkey-node',
'--client-version',
'1.2.7' ],
error: [Circular],
status: null,
signal: null,
output: null,
pid: 19,
stdout: null,
stderr: null }
END RequestId: 0e0f9e4f-fc9c-4365-8556-3e909d4e8699
REPORT RequestId: 0e0f9e4f-fc9c-4365-8556-3e909d4e8699
Duration: 155.14 ms Billed Duration: 200 ms Memory Size: 3008 MB Max Memory Used: 28 MB
RequestId: 0e0f9e4f-fc9c-4365-8556-3e909d4e8699 Error: Runtime exited with error: exit status 1
Runtime.ExitError
Oops - looks like I need to revoke that envkey now. (In case any clever hackers were attempting to see my secrets). But yeah, still no dice
I figured it out. https://spectrum.chat/zeit/now/using-exec-and-node-module-path-directory-in-now-node~143259bd-7071-441f-b95d-a4733e2ba045
Basically, ncc
strips out everything and removes node_modules
. I guess for now, I can use envkey-node
as a submodule in my repo
Actually, I'm also using https://github.com/joshwnj/ffprobe-static and this executes fine within now.sh
. So I'm not sure why those binaries aren't being stripped out?
Got it to work (for now). Work around was to:
now.json
, I have:
"builds": [{
"src": "index.js",
"use": "@now/node",
"config": {
"bundle": false,
"includeFiles": [
"node_modules/envkey/**"
]
}
}],
Ah, I was thinking that module size might be the culprit, but was thrown off by the fact that your var resp = execFileSync(filePath, execArgs).toString()
seemed to work. And yes, forking and removing unneeded binaries is the recommendation for dealing with that until platform-specific module loading gets done (it's on the roadmap, but so are lots of other things 😬).
That's the error I get.