Home / Function/ then() — fastify Function Reference

then() — fastify Function Reference

Architecture documentation for the then() function in reply.js from the fastify codebase.

Entity Profile

Dependency Diagram

graph TD
  f26bdb28_b830_3aec_800b_087055150c6c["then()"]
  4bcd71dc_1ec2_5fe8_b8ff_4a371e392925["reply.js"]
  f26bdb28_b830_3aec_800b_087055150c6c -->|defined in| 4bcd71dc_1ec2_5fe8_b8ff_4a371e392925
  e86de8a4_fcf2_726c_6613_1273524e94e2["sendWebStream()"]
  e86de8a4_fcf2_726c_6613_1273524e94e2 -->|calls| f26bdb28_b830_3aec_800b_087055150c6c
  944c1a61_ec49_25f7_bdf7_a5b89cd52706["sendTrailer()"]
  944c1a61_ec49_25f7_bdf7_a5b89cd52706 -->|calls| f26bdb28_b830_3aec_800b_087055150c6c
  style f26bdb28_b830_3aec_800b_087055150c6c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

lib/reply.js lines 454–473

Reply.prototype.then = function (fulfilled, rejected) {
  if (this.sent) {
    fulfilled()
    return
  }

  eos(this.raw, (err) => {
    // We must not treat ERR_STREAM_PREMATURE_CLOSE as
    // an error because it is created by eos, not by the stream.
    if (err && err.code !== 'ERR_STREAM_PREMATURE_CLOSE') {
      if (rejected) {
        rejected(err)
      } else {
        this.log && this.log.warn('unhandled rejection on reply.then')
      }
    } else {
      fulfilled()
    }
  })
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does then() do?
then() is a function in the fastify codebase, defined in lib/reply.js.
Where is then() defined?
then() is defined in lib/reply.js at line 454.
What calls then()?
then() is called by 2 function(s): sendTrailer, sendWebStream.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free