Skip to content

Ensure all value types can be logged with console.log w/ redaction #134

Closed
@DavidWells

Description

@DavidWells

Getting some console.log issues when trying to log out an execa subprocess in a plugin.

async function runThing(cmd, opts) {
  const cwdPath = resolveConfigPath(opts.config)
  const subprocess = execa(`${cmd}`, {
    cwd: cwdPath,
    shell: true,
  })
  subprocess.stdout.pipe(process.stdout, { end: true })
  try {
    const { stdout } = await subprocess
    return stdout
  } catch (err) {
    console.log(subprocess)
    throw new Error(err)
  }
}

Stack trace:

 err TypeError: obj.hasOwnProperty is not a function
    at DeepMap.mapObject (/Users/davidwells/Netlify/projects/build/netlify-build/packages/@netlify-build/node_modules/deep-map/lib/deep-map.js:49:21)
    at DeepMap.map (/Users/davidwells/Netlify/projects/build/netlify-build/packages/@netlify-build/node_modules/deep-map/lib/deep-map.js:27:45)
    at DeepMap.mapObject (/Users/davidwells/Netlify/projects/build/netlify-build/packages/@netlify-build/node_modules/deep-map/lib/deep-map.js:50:36)
    at DeepMap.map (/Users/davidwells/Netlify/projects/build/netlify-build/packages/@netlify-build/node_modules/deep-map/lib/deep-map.js:27:45)
    at deepMap (/Users/davidwells/Netlify/projects/build/netlify-build/packages/@netlify-build/node_modules/deep-map/lib/deep-map.js:16:40)
    at redactValues (/Users/davidwells/Netlify/projects/build/netlify-build/packages/@netlify-build/src/utils/redact.js:13:10)
    at args.map.a (/Users/davidwells/Netlify/projects/build/netlify-build/packages/@netlify-build/src/utils/patch-logs.js:26:29)
    at Array.map (<anonymous>)
    at Object.apply (/Users/davidwells/Netlify/projects/build/netlify-build/packages/@netlify-build/src/utils/patch-logs.js:15:33)
    at runThing (/Users/davidwells/Netlify/projects/build/netlify-build/example/plugins/serverless-plugin/index.js:61:13)

It appears that deep-map logic doesn't like this object

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions