Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

fs.createReadStream and --compress#1158

Merged
robertsLando merged 2 commits intovercel:masterfrom
node-opcua:Feature/fs.createReadStream
May 13, 2021
Merged

fs.createReadStream and --compress#1158
robertsLando merged 2 commits intovercel:masterfrom
node-opcua:Feature/fs.createReadStream

Conversation

@erossignon
Copy link
Copy Markdown
Contributor

@erossignon erossignon commented May 1, 2021

@Hypfer , this should fix issue found with compressed pkg file and streaming file from snapshot.

@erossignon erossignon force-pushed the Feature/fs.createReadStream branch 5 times, most recently from 5c47a9f to 89eb14e Compare May 1, 2021 21:22
@erossignon erossignon marked this pull request as draft May 1, 2021 21:34
@erossignon erossignon force-pushed the Feature/fs.createReadStream branch 2 times, most recently from 4ded3af to 2bea2b8 Compare May 1, 2021 22:22
@erossignon erossignon marked this pull request as ready for review May 2, 2021 06:30
@erossignon erossignon requested a review from robertsLando May 2, 2021 06:30
@erossignon erossignon force-pushed the Feature/fs.createReadStream branch 2 times, most recently from a22eaad to 61a465c Compare May 2, 2021 08:19
Comment thread prelude/bootstrap.js
Comment thread prelude/bootstrap.js
const os = require('os');
const tmpFolder = fs.mkdtempSync(path.join(os.tmpdir(), 'pkg-'));
process.on('beforeExit', () => {
removeTemporaryFolderAndContent(tmpFolder);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed? Couldn't we keep files in temporary folder for quicker startup?

Copy link
Copy Markdown
Contributor Author

@erossignon erossignon May 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • This is a boy scout attitude. Leave the place tidier than you found it.
  • Those files potentially are exposed in clear,
  • Arguably, those files could be corrupted later on somehow, the single source of truth is in the packed binary.
  • Only files that are randomly accessed are copied uncompressed in this folder. I made sure that file that are read globally (readFileSync) or streamed (createReadStream) are processed in memory. I would be inclined to leave it this way unless users complain about potential performance issue.
  • having a persistent cache would require that the temp subfolder name is stable and unique, based on the executable signature (shall we calculated the md5/sha1 of the entire pkg.exe ?)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having a persistent cache would require that the temp subfolder name is stable and unique, based on the executable signature (shall we calculated the md5/sha1 of the entire pkg.exe ?)

Could be an idea but yeah those files could be someway corrupted. I would like to also know @jesec and @leerob opinion about this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might also be an option to generate a build-id uuid on build and bake that into the binary.

Comment thread prelude/bootstrap.js
@jesec
Copy link
Copy Markdown
Contributor

jesec commented May 11, 2021

@erossignon Please rebase the PR. Apparently, I am not able to do this for you:

remote: Permission to node-opcua/pkg.git denied to jesec.

Despite some concerns about race conditions, I think we can merge this PR, as the change appears to be self-contained, and should not hurt no compress case.

@erossignon erossignon force-pushed the Feature/fs.createReadStream branch from 2c49066 to ce9b944 Compare May 11, 2021 12:00
@robertsLando robertsLando self-requested a review May 11, 2021 13:19
Copy link
Copy Markdown
Contributor

@robertsLando robertsLando left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@erossignon erossignon force-pushed the Feature/fs.createReadStream branch from ce9b944 to 65d3036 Compare May 13, 2021 06:56
@robertsLando
Copy link
Copy Markdown
Contributor

Could this be merged?

@erossignon
Copy link
Copy Markdown
Contributor Author

Sure !

@robertsLando robertsLando merged commit ea23196 into vercel:master May 13, 2021
@erossignon erossignon deleted the Feature/fs.createReadStream branch May 21, 2021 17:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fs.promises provided by Pkg does not implement the same API as defined in Node.js

4 participants