driverdan / node-XMLHttpRequest

XMLHttpRequest for node.js
http://thedanexperiment.com/2009/10/04/emulating-xmlhttprequest-in-node-js/
MIT License
416 stars 299 forks source link

Write temp files to /tmp #157

Open barodeur opened 6 years ago

barodeur commented 6 years ago

As suggested by @lucabarze in https://github.com/driverdan/node-XMLHttpRequest/issues/145 this fix should fix the problem we have when using sync requests on AWS Lambda.

demsey2 commented 6 years ago

I tried that with AWS Lambda and it works fine, however, my initial issue was with Google Cloud Function. The introduced changed in this PR doesn't work. I believe the main problem is with a different approach to the /tmp directory in GCF. According to their docs "Cloud Functions provides access to a local disk mount point (/tmp) which is known as a "tmpfs" volume in which data written to the volume is stored in memory.". So when we create syncFile in the parent process and then we try to unlink in the child process, it doesn't work the file doesn't exist. So we end up with an infinite loop caused by the while loop.

I managed to fix that by calling spawnSync to check if syncFile exists in the child process.

barodeur commented 6 years ago

Sorry to hear this doesn't help you. Do you confirm that node-XMLHttpRequest works with Lambda without this fix? Should I close this pull request?

demsey2 commented 6 years ago

you need that fix for AWS Lambda for Google Functions you need more changes

barodeur commented 6 years ago

Thanks for the clarification

hmoog commented 6 years ago

checkout https://www.npmjs.com/package/xmlhttprequest-ts - i added your pull request