Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file collision when running in workers. #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/XMLHttpRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
var Url = require("url");
var spawn = require("child_process").spawn;
var fs = require("fs");
var uuid = require("uuid")

exports.XMLHttpRequest = function() {
"use strict";
Expand Down Expand Up @@ -476,8 +477,9 @@ exports.XMLHttpRequest = function() {
self.dispatchEvent("loadstart");
} else { // Synchronous
// Create a temporary file for communication with the other Node process
var contentFile = ".node-xmlhttprequest-content-" + process.pid;
var syncFile = ".node-xmlhttprequest-sync-" + process.pid;
var uniqueId = process.pid + "-" + uuid.v4();
var contentFile = ".node-xmlhttprequest-content-" + uniqueId;
var syncFile = ".node-xmlhttprequest-sync-" + uniqueId;
fs.writeFileSync(syncFile, "", "utf8");
// The async request the other Node process executes
var execString = "var http = require('http'), https = require('https'), fs = require('fs');"
Expand Down
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
{
"name": "xmlhttprequest",
"description": "XMLHttpRequest for Node",
"version": "1.8.0",
"version": "1.8.1",
"author": {
"name": "Dan DeFelippi",
"url": "http://driverdan.com"
},
"keywords": ["xhr", "ajax"],
"keywords": [
"xhr",
"ajax"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/driverdan/node-XMLHttpRequest.git"
},
"browser": "./lib/browser.js",
"browser": {
"fs": false,
"child_process": false
},
"bugs": "http://github.com/driverdan/node-XMLHttpRequest/issues",
"engines": {
"node": ">=0.4.0"
Expand All @@ -22,8 +28,7 @@
"example": "./example"
},
"main": "./lib/XMLHttpRequest.js",
"browser": {
"fs": false,
"child_process": false
"dependencies": {
"uuid": "^8.3.2"
}
}