code: function resolvePage () {
        try {
          if (body.waitForJS === true && !pageJSisDone) {
            setTimeout(function () {
              resolvePage()
            }, 100)
  
            return
          }
  
          var resultData = page.evaluate(function (rawFnSource, customArgs) {
            var fnSource = rawFnSource.trim()
  
            fnSource = fnSource.slice(-1) === ';' ? fnSource.slice(0, -1) : fnSource
  
            var fn = '(function result() { '
            fn += 'return (' + fnSource + ') '
            fn += '})()'
  
            try {
              // eslint-disable-next-line
              fn = window.eval(fn)
            } catch (e) {
              // eslint-disable-next-line no-template-curly-in-string
              return {
                error: 'script code passed as `scriptFn` option has syntax error: ' + e.message
              }
            }
  
            if (typeof fn !== 'function') {
              return {
                error: 'script code passed as `scriptFn` option is not a function'
              }
            }
  
            return {
              result: fn.apply(null, customArgs)
            }
          }, body.scriptFn, body.args)
  
          // resultData can still be null if evaluated script returned
          // non-serializable value
          if (resultData && resultData.error) {
            throw new Error(resultData.error)
          }
  
          fs.write(body.outputFilePath, JSON.stringify({
            result: resultData != null ? resultData.result : undefined
          }), 'w')
  
          respond(page, {
            empty: resultData == null,
            logs: messages
          })
        } catch (e) {
          onMainError(e)
        }
      }
docs: eslint-disable-next-line no-inner-declarations