evanw/esbuild · error · Error

Missing second argument in ${callName}() call

Error message

Missing second argument in ${callName}() call

What it means

Error "Missing second argument in ${callName}() call" thrown in evanw/esbuild.

Source

Thrown at lib/shared/common.ts:789

      } catch (e) {
        let flags: string[] = []
        try { pushLogFlags(flags, options, {}, isTTY, transformLogLevelDefault) } catch { }
        const error = extractErrorMessageV8(e, streamIn, details, void 0, '')
        sendRequest(refs, { command: 'error', flags, error }, () => {
          error.detail = details.load(error.detail)
          callback(failureErrorWithLog('Transform failed', [error], []), null)
        })
      }
    }
    if ((typeof input === 'string' || input instanceof Uint8Array) && input.length > 1024 * 1024) {
      let next = start
      start = () => fs.writeFile(input, next)
    }
    start(null)
  }

  let formatMessages: StreamService['formatMessages'] = ({ callName, refs, messages, options, callback }) => {
    if (!options) throw new Error(`Missing second argument in ${callName}() call`)
    let keys: OptionKeys = {}
    let kind = getFlag(options, keys, 'kind', mustBeString)
    let color = getFlag(options, keys, 'color', mustBeBoolean)
    let terminalWidth = getFlag(options, keys, 'terminalWidth', mustBeInteger)
    checkForInvalidFlags(options, keys, `in ${callName}() call`)
    if (kind === void 0) throw new Error(`Missing "kind" in ${callName}() call`)
    if (kind !== 'error' && kind !== 'warning') throw new Error(`Expected "kind" to be "error" or "warning" in ${callName}() call`)
    let request: protocol.FormatMsgsRequest = {
      command: 'format-msgs',
      messages: sanitizeMessages(messages, 'messages', null, '', terminalWidth),
      isWarning: kind === 'warning',
    }
    if (color !== void 0) request.color = color
    if (terminalWidth !== void 0) request.terminalWidth = terminalWidth
    sendRequest<protocol.FormatMsgsRequest, protocol.FormatMsgsResponse>(refs, request, (error, response) => {
      if (error) return callback(new Error(error), null)
      callback(null, response!.messages)
    })

View on GitHub (pinned to 6ff1d8b0d8)

Solutions

  1. Pass the options object as the second argument to the API call
  2. Provide the required second argument even if it is an empty object

Example fix

await esbuild.transform(code, { loader: 'ts' });
// or with explicit empty options:
await esbuild.transform(code, {});

When it happens

Trigger: Thrown at lib/shared/common.ts:789 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of evanw/esbuild@6ff1d8b0d8 (2026-08-03). Data as JSON: /data/errors/a3cd13dcf62a7e89.json. Report an issue: GitHub.