Double request when chrome developer tools open

主宰稳场 提交于 2021-02-08 12:59:33

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/24937015/double-request-when-chrome-developer-tools-open

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!