Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Double request when chrome developer tools open

I've an odd problem, i have a very simple node/expressjs app ( i have a much more complex one but this simple example shows the problem ). This app has three routes as shown here:

var i = 0;

app.route('/login')
.get(function(req, res){
    console.log('login', ++i);

    res.send('login');
})

app.route('/test')
.get(function(req, res){
    console.log('test', ++i);

    res.send('test');
})

app.route('/')
.get(function(req, res){
    console.log('index', ++i);

    res.send('index');
})

Pretty simple. Any time one of these routes is requested 'i' is incremented and logged, and it works fine, except when the chrome dev tools is open. When the dev tools are open requesting either login or test will be requested twice. Here is the results of the log:

15:45:30 web.1  | index 1
15:45:33 web.1  | login 2
15:45:34 web.1  | login 3
15:45:37 web.1  | test 4
15:45:37 web.1  | test 5
15:45:41 web.1  | login 6
15:45:42 web.1  | login 7
15:45:45 web.1  | test 8
15:45:45 web.1  | test 9
15:45:48 web.1  | index 10

Whats going on here. Is it a Chrome bug?

Adam

like image 714
adamdaly Avatar asked Jul 24 '14 14:07

adamdaly


1 Answers

This is a semi-known issue with chrome.

Google has a discussion here that discusses possible work arounds-- I haven't found a real solution, but this should give you a good head start.

https://code.google.com/p/chromium/issues/detail?id=64810

like image 179
bencripps Avatar answered Nov 04 '22 23:11

bencripps