-
Notifications
You must be signed in to change notification settings - Fork 23
Node.js exits while waiting for auth.getContainer (and other functions) #250
Comments
I think it's simply that When I run
I get the same outcome whether or not
run fine every time. By the way, I'm running at commit e818f8a |
Although I see that I may simply not be able to reproduce the behavior in your environment. In my above example, I was running that code in the |
Thanks for looking at the issue!
The code is put in a file called
I have installed the latest from npmjs.com, which is The example code gives the following output (with
And without the
That's correct, but that's not what the code does (mind the parentheses): The issue here is that the Node.js script does not error but somehow exits without waiting for the promise. A couple of hours ago I started to think this is also the reason that people on the SAFE Dev forum encounter situations where the output is not what it is expected to be, without errors:
I've looked into it a bit past few weeks but given up. It seems some calls just cause the Node.js script to exit. The takeaway here is that there are no errors! |
@b-zee I tried
And it error'd, so I thought maybe I wasn't doing it right. Anyway, here's what I get:
Using:
|
That seems like a different issue. Maybe worth making another issue from @hunterlester? I actually think that's the issue which I reported on the SAFE Dev forum: https://forum.safedev.org/t/loginfortest-with-two-apps/1752?u=bzee |
@b-zee Ah I see now, thank you. |
Great! Hope it will be picked up soon, seems like a critical issue. Might cause all kinds of seemingly random behaviour in apps. |
I wasn't able to reproduce this exactly as reported, I'm using node v8.11.1, and this is what I'm experiencing wither with safe_app_nodejs v0.8.1 or with commit e818f8a:
|
Does it just never return the I am using the same Node.js version. I have tested this on Windows 10 by the way. |
It always returns the |
Aha, I knew I'd seen this somewhere. I've just come across this when trying to write immutable data. https://github.com/joshuef/poc-safe-cli/blob/master/src/upload/handleFileUpload.js#L37-L49 const data = await fs.readFileSync( theFilePath ).toString();
const writer = await app.immutableData.create()
// TODO: Why is this needed?
delay( 2000 )
await writer.write( data )
// almost never reaches here. <----
const cipher = await app.cipherOpt.newPlainText();
const mimeType = 'text/plain';
const address= await writer.close( cipher, true, mimeType ); Again, without a I've dug around extensively checking FWIW I've encountered it on MacOS and Ubuntu 18. This test case seems pretty reliable. |
Consider the following example:
When running the above, all is well. When removing the
setTimeout
, the Node.js script will exit after thegetContainer
is run.The
setTimeout
puts a callback in the queue that prevents Node.js from exiting. I think the API should also put something in the queue to prevent the Node.js process from thinking it's done.My hypothesis is that is has something to do with how the FFI works. The same happens when calling
getContainersPermissions
, so I assume it's just about any FFI function.The text was updated successfully, but these errors were encountered: