Skip to content

module http or request stops on middle of transfers 0.32.3 #2809

Closed

Description

@MikeGCV

When transferring a file using the http module get method, on 0.32.3 windows x64, the transfer doesn't finish, mostly on big files.
In 0.32.2 no problem

Activity

  1. zcbenz commented on Sep 17, 2015

    @zcbenz
    Contributor

    Can you provide an example?

  2. MikeGCV commented on Sep 18, 2015

    @MikeGCV
    Author

    As i was making an example of this issue, i saw that 0.33.0 was released. Tested the same code against 0.33.0 and no problem. Very strange. Well, seems solved.

  3. MikeGCV commented on Sep 19, 2015

    @MikeGCV
    Author

    The problem has returned, i don't understand, in 0.32.2 this code works perfectly:

            var _fs = require('fs');
            var request = require('request');
    
            var _file = _fs.createWriteStream(path + '/' + file, { bufferSize: 64 * 1024 });
            var cur = 0;
            var req = request({
                method: 'GET',
                uri: _app.serverIP + '/resources/files/' + file
            });
    
            req.on('response', function ( data ) {
                console.log(data.statusCode);
                console.log( data.headers[ 'content-length' ] );
    
                req.pipe(_file);
                _file.on('finish', function() {
                    _file.close(resolve);
                    _file = null;
                });
            });
    
            req.on('data', function (chunk) {
                //console.log(chunk.length);
                cur += chunk.length;
                console.log((100.0 * cur / total).toFixed(0));
            });
    
            req.on('error', function(err){
                _fs.unlink(path + '/' + file);
                reject(err);
            });
    
            req.on('end', function() {
                req = null;
            });
    

    In 0.32.3 and 0.33 gives me this error on big files: ESOCKETTIMEDOUT. This is executed in the renderer process.

    Thanks

  4. MikeGCV commented on Sep 19, 2015

    @MikeGCV
    Author

    Same error happening in the main process, no errors on 0.32.2. This is in windows.

  5. MikeGCV commented on Sep 20, 2015

    @MikeGCV
    Author

    Just tested in Linux, same error on 0.33

  6. changed the title [-]module http stops on middle of transfers 0.32.3[/-] [+]module http or request stops on middle of transfers 0.32.3[/+] on Sep 20, 2015
  7. zcbenz commented on Sep 21, 2015

    @zcbenz
    Contributor

    It is hard to determine since you are sending a request to your own server, can you try if following example works?

    var req = require('request')('https://github.com');
    var file = require('fs').createWriteStream(process.env.USERPROFILE + '/Desktop/test.html');
    req.on('response', function() {
      req.pipe(file);
    });

    Also if you are creating a server inside Electron you have to paste a full example, otherwise it would be impossible to debug this since the cause is very likely to be in other parts of your code.

  8. added
    blocked/need-info ❌
    on Sep 21, 2015
  9. MikeGCV commented on Sep 22, 2015

    @MikeGCV
    Author

    It's an external server, i've been doing some tests, it's very strange, your code works perfectly, but not for big files, i will be doing more tests tomorrow. The most frequent error is RangeError: length out of bounds

  10. MikeGCV commented on Sep 22, 2015

    @MikeGCV
    Author

    Ok, here's my scripts, nothing interfering, this is on 0.33.1 windows 8.1.

    main.js loaded in the renderer

    window.addEventListener('DOMContentLoaded', function () {
        'use strict';
    
        var req = require('request')  ('http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_normal.mp4');
        var file = require('fs').createWriteStream(__dirname + '/testing.mp4');
    
        req.on('response', function() {
            console.log('Transfer start');
            req.pipe(file);
        });
    
        req.on('end', function(){
             console.log('Transfer end');
        });
    });
    

    app.js for the main process:

    'use strict';
    const app = require('app');
    const BrowserWindow = require('browser-window');
    
    let mainWindow;
    
    function onClosed() {
    mainWindow = null;
    }
    
    function createMainWindow() {
    const win = new BrowserWindow({
        width: 600,
        height: 400
    });
    
    win.loadUrl(`file://${__dirname}/index.html`);
    win.on('closed', onClosed);
    win.webContents.on('dom-ready', function(){
        win.openDevTools({detach: true});
    });
    return win;
    }
    
    app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
        app.quit();
    }
    });
    
    app.on('activate-with-no-open-windows', () => {
    if (!mainWindow) {
        mainWindow = createMainWindow();
    }
    });
    
    app.on('ready', () => {
    mainWindow = createMainWindow();
    });
    

    Many times, the download fails with timeouts or RangeError: length out of bounds.
    In version 0.32.2 this never happens

  11. added and removed
    blocked/need-info ❌
    on Sep 23, 2015
  12. zcbenz commented on Sep 23, 2015

    @zcbenz
    Contributor

    Thanks for the test case, it seems that the length of Buffer becomes zero sometimes.

  13. Akgupta11 commented on Apr 11, 2018

    @Akgupta11

    i am getting an error of ESOCKETTIMEDOUT and ETIMEDOUT in case of blynk app for using google voice assistant to operate my command as turning ON the LED and turning OFF the LED. it will be so helpful i get any help related to this issue. Anyone of can share the solution for this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions