node.js を使用して REST API サービスを作成しましたが、ブラウザーでいくつかのタブを開き、(ほぼ) 同時にいくつかの要求を行うまで、完全に機能します。リクエストを送信した最後のタブが応答を受け取り、もう一方のタブがハングします。
基本的に、すべての作業を行う「サービス」というモジュールがあります。
var service = require('./service');
var server = http.createServer(function(req, res) {
    ...
    var serviceResult = service.runService(parsedURL.query.username, parsedURL.query.api_key);
    res.writeHead(200, {'content-type': 'application/json', 'connection' : 'keep-alive' });
    service.ready = function(serviceResult) {
        var serviceResultJSON = JSON.stringify(serviceResult);
        res.writeHead(200, {'content-type': 'application/json', 'connection' : 'close' });
        res.end(serviceResultJSON);
    }
}
そして、私が呼び出すサービスモジュールから:
service.ready(result);
...結果の準備ができたらいつでも、それが私のサーバーです。では、どうすれば問題を解決できますか?
編集:
これが私のservice.jsモジュールの外観です(提案された変更後):
// PUBLIC
exports.runService = function(username, apiKey, callback) {
    _.username              = username;
    _.apiKey                = apiKey;
    init();
    userManager.setLastServiceGlobal(function() {
            // This call triggers the whole cycle. Below is snapshotManager.createdSnapshot(), which gets executed from within snapshotManager and the cycle moves on until apiManager.ready() gets called from within api-manager.js
        snapshotManager.createSnapshot(false);
    });
    // This is the last .ready() function that gets executed when all other modules have finished their job.
    apiManager.ready = function() {
        console.log('API Manager ready.');
        userManager.updateLastService();
        callback(null, serviceResult);
    }
}
// PRIVATE
var userManager             = require('./user-manager'),
    productManager          = require('./product-manager'),
    commentsManager         = require('./comments-manager'),
    apiManager          = require('./api-manager'),
    milestonesManager       = require('./milestones-manager'),
    statisticsManager       = require('./statistics-manager'),
    snapshotManager         = require('./snapshot-manager'),
    serviceResult;
...
snapshotManager.createdSnapshot = function() {
    userManager.refreshUserData();
}
snapshotManager.createdNewSnapshot = function() {
    milestonesManager.generateMilestones();
}
userManager.refreshedUserData = function() {
    userManager.isTimeForPortfolioParse();
}
...
userManager.ready = function() {
    console.log('User Manager ready.');
    userManagerReady = true;
    isDataFetchingOver();
}
productManager.ready = function() {
    console.log('Product Manager ready.');
    productManagerReady = true;
    isDataFetchingOver();
}
commentsManager.ready = function() {
    console.log('Comments Manager ready.');
    commentsManagerReady = true;
    isDataFetchingOver();
}
この状況では、「server.js」ファイルの「service」モジュールと同じようにモジュールがオーバーライドされていますよね?.ready() 関数の代わりにコールバックをどこにでも実装する必要があると思いますよね?