MCPcopy
hub / github.com/vercel/next.js / after

Method after

packages/next/src/server/after/after-context.ts:39–53  ·  view source on GitHub ↗
(task: AfterTask)

Source from the content-addressed store, hash-verified

37 }
38
39 public after(task: AfterTask): void {
40 if (isThenable(task)) {
41 if (!this.waitUntil) {
42 errorWaitUntilNotAvailable()
43 }
44 this.waitUntil(
45 task.catch((error) => this.reportTaskError('promise', error))
46 )
47 } else if (typeof task === 'function') {
48 // TODO(after): implement tracing
49 this.addCallback(task)
50 } else {
51 throw new Error('`after()`: Argument must be a promise or a function')
52 }
53 }
54
55 private addCallback(callback: AfterCallback) {
56 // if something is wrong, throw synchronously, bubbling up to the `after` callsite.

Callers 1

afterFunction · 0.45

Calls 6

reportTaskErrorMethod · 0.95
addCallbackMethod · 0.95
isThenableFunction · 0.90
waitUntilMethod · 0.45
catchMethod · 0.45

Tested by

no test coverage detected