Open ValentinSteiner opened 2 years ago
@ValentinSteiner Thanks for posting! We'll take a look as soon as possible.
In the mean time, there are a few ways you can help speed things along:
Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.
For help with questions about Sails, click here.
Hi @ValentinSteiner, The workaround you posted is how we recommend handling asynchronous scripts. You can look at the Parley readme to learn more about this.
Node version: v16.13.1 Sails version (sails): 1.4.2 ORM hook version (sails-hook-orm): sails-hook-orm@3.0.2 Sockets hook version (sails-hook-sockets): sails-hook-sockets@2.0.1 Organics hook version (sails-hook-organics): sails-hook-organics@2.2.0 Grunt hook version (sails-hook-grunt): sails-hook-grunt@4.0.1 Uploads hook version (sails-hook-uploads): n/a DB adapter & version (e.g. sails-mysql@5.55.5): n/a Skipper adapter & version (e.g. skipper-s3@5.55.5): n/a
Problem statement
I noticed that a shell script invoked through
sails run myscript
exits without waiting for a file stream to be read. I expected the node process to exit only after the file stream has been read entirely.Steps to reproduce
sails new test-project
and select 1 / Web App.scripts/myscript.js
with the following contents:module.exports = { friendlyName: 'myscript',
};
const fs = require('fs');
module.exports = { friendlyName: 'myscript2',
};
const fs = require('fs');
fs.createReadStream('/tmp/data.txt') .on('data', data => console.log(data.toString())) .on('end', () => console.log('ended'));