chrome开发人员工具打开时出现双重要求 [英] Double request when chrome developer tools open

查看:77
本文介绍了chrome开发人员工具打开时出现双重要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题,我有一个非常简单的node/expressjs应用程序(我有一个更复杂的应用程序,但这个简单的示例显示了问题).这个应用程式有3条路线,如下所示:

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');
})

非常简单.每当请求这些路由之一时,"i"都会递增并记录下来,并且工作正常,除非打开了chrome dev工具.当开发工具打开时,将要求登录或测试两次.这是日志的结果:

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

这是怎么回事.是Chrome的错误吗?

Whats going on here. Is it a Chrome bug?

亚当

推荐答案

这是chrome的一个半已知问题.

This is a semi-known issue with chrome.

Google在这里进行了讨论,讨论了可能的解决方法-我还没有找到真正的解决方案,但这应该为您提供一个良好的开端.

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

这篇关于chrome开发人员工具打开时出现双重要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆