message: refactor(helpers): record message call context on debug
diff: @@ -317,14 +317,16 @@ function messageSend<T extends MsgType, R = MessageResponse<T>>(
  function messageSend<T extends MsgType>(
  ...args: [Message<T>] | [number, Message<T>]
  ): Promise<any> {
  + let callContext: Error
  + if (process.env.DEBUG) {
  + callContext = new Error('Message Call Context')
  + }
  return (args.length === 1
  ? browser.runtime.sendMessage(args[0])
  : browser.tabs.sendMessage(args[0], args[1])
  ).catch(err => {
  if (process.env.DEBUG) {
  - console.warn(err, ...args)
  - } else if (process.env.NODE_ENV !== 'production') {
  - return Promise.reject(err) as any
  + console.warn(err.message, ...args, callContext)
  }
  })
  }
  @@ -332,6 +334,11 @@ function messageSend<T extends MsgType>(
  async function messageSendSelf<T extends MsgType, R = undefined>(
  message: Message<T>
  ): Promise<R extends undefined ? MessageResponse<T> : R> {
  + let callContext: Error
  + if (process.env.DEBUG) {
  + callContext = new Error('Message Call Context')
  + }
  +
  if (window.pageId === undefined) {
  await initClient()
  }
  @@ -344,9 +351,7 @@ async function messageSendSelf<T extends MsgType, R = undefined>(
  )
  .catch(err => {
  if (process.env.DEBUG) {
  - console.warn(err, message)
  - } else if (process.env.NODE_ENV !== 'production') {
  - return Promise.reject(err) as any
  + console.warn(err.message, message, callContext)
  }
  })
  }
  