Welcome to the Linux Foundation Forum!

fastify - is then method on reply object is a custom method implemented specifically by fastify ?

fastify - is then method on reply object is a custom method implemented specifically by fastify ?

I can appreciate the await reply. but since reply is not a promise, i wonder it can't call the then method of a promise.

so, i believe then method is implemented seperately on a reply object?

can someone confirm my understanding? highly appreciated.
thank you.

Comments

  • Posts: 160
    edited September 2022

    yes the await syntax causes a then method to be called on whatever object is awaited. A plain object with a then method is informally known as a "thenable", Fastify is probably using thenables as a performance optimization (from memory I think awaiting a thenable is faster/uses less resources, for a start it eliminates a lot of the internal mechanics that promises introduce around asynchronous catch handlers).

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training