简体   繁体   English

是什么导致 express.js 请求中的可读字段设置为 false?

[英]What causes the readable field to be set to false in express.js request?

New to expressjs and trying to debug the following issue I'm having locally: expressjs 新手并尝试调试我在本地遇到的以下问题:

  1. The GET /health endpoint check works with 200 status response GET /health 端点检查适用于 200 状态响应
  2. the POST /login endpoint doesn't even appear to fire when running locally (I added a "console.log" statement in the corresponding controller function that would be called by the express.js router and it never gets fired) - what I notice when I do console.log(req) in the main error handler is that this readable field is marked false whereas in the /health endpoint it's marked true: POST / login 端点在本地运行时甚至似乎都不会触发(我在相应的 controller function 中添加了一个“console.log”语句,该语句将由 express.js 路由器调用并且它永远不会被触发) - 我注意到当我在主错误处理程序中执行console.log(req)时,这个readable字段被标记为false而在 /health 端点中它被标记为 true:
    req: IncomingMessage {
        _readableState: ReadableState {
          objectMode: false,
          highWaterMark: 16384,
          buffer: BufferList { head: null, tail: null, length: 0 },
          length: 0,
          pipes: null,
          pipesCount: 0,
          flowing: true,
          ended: true,
          endEmitted: true,
          reading: false,
          sync: false,
          needReadable: false,
          emittedReadable: false,
          readableListening: false,
          resumeScheduled: false,
          emitClose: true,
          autoDestroy: false,
          destroyed: false,
          defaultEncoding: 'utf8',
          awaitDrainWriters: null,
          multiAwaitDrain: false,
          readingMore: false,
          decoder: null,
          encoding: null,
          [Symbol(kPaused)]: false
        },
        readable: false,

This just started happening in the past day or so so it's really baffling what change could have been made that would affect the POST /login endpoint's ability to fire when the server is run locally.这只是在过去一天左右才开始发生,所以当服务器在本地运行时,可能进行了哪些更改会影响 POST /login 端点的触发能力,这真是令人困惑。

An express request is a IncomingMessage which is a readable stream and inherits its .readable property :一个快速请求是一个IncomingMessage ,它是一个可读的 stream并继承了它的.readable属性

Is true if it is safe to call readable.read() , which means the stream has not been destroyed or emitted 'error' or 'end'.如果调用readable.read()是安全的,则为true ,这意味着 ZF7B44CFFAFD5C52223D5498196C8A2E7BZ 尚未被销毁或发出“错误”或“结束”。

In short it means that the stream has not yet been completely consumed.简而言之,这意味着 stream 尚未完全消耗。 Since the body of a GET request is ignored (it has none), none of your middlewares will have read it, in contrast to the POST request.由于 GET 请求的主体被忽略(它没有),与 POST 请求相比,您的中间件都不会读取它。 So this is expected, and doesn't help with your actual problem.所以这是意料之中的,对您的实际问题没有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM