Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bare Error instance does not log correctly #944

Open
kumavis opened this issue Nov 30, 2021 · 9 comments
Open

bare Error instance does not log correctly #944

kumavis opened this issue Nov 30, 2021 · 9 comments
Assignees
Labels
good first issue Good for newcomers kriskowal-just-do-it-2024-01 Tasks that kriskowal can close out quickly to clear weeds kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024

Comments

@kumavis
Copy link
Member

kumavis commented Nov 30, 2021

ses: (master at time of writing ac1cc0)
node: v14.17.6 (and v16.9.1, v17.2.0)

require('ses/lockdown');
lockdown({ errorTaming: 'unsafe', stackFiltering: 'verbose', consoleTaming: 'unsafe', domainTaming: 'unsafe' })
console.error(new Error('boom'));

logs only

{}

error stack and message are intact

previous issue #636

@kumavis
Copy link
Member Author

kumavis commented Nov 30, 2021

with overideTaming: 'min'

[Error: boom
  at file:///home/xyz/Development/endo/packages/ses/abc.js:10:13
  at ModuleJob.run (internal/modules/esm/module_job.js:170:25)
  at async Loader.import (internal/modules/esm/loader.js:178:24)
  at async Object.loadESM (internal/process/esm_loader.js:68:5)]

with overideTaming: 'moderate'(default)

{}

with overideTaming: 'severe'

[Error <Object <[Object: null prototype] {}>>: boom
  at file:///home/xyz/Development/endo/packages/ses/abc.js:10:13
  at ModuleJob.run (internal/modules/esm/module_job.js:170:25)
  at async Loader.import (internal/modules/esm/loader.js:178:24)
  at async Object.loadESM (internal/process/esm_loader.js:68:5)]

@kumavis
Copy link
Member Author

kumavis commented Nov 30, 2021

lockdown({ overrideTaming, errorTaming: 'unsafe', stackFiltering: 'verbose', consoleTaming: 'unsafe' });
console.log(Object.getOwnPropertyDescriptors(Error.prototype));
  • min:
{
  constructor: {
    value: [Function: Error],
    writable: false,
    enumerable: false,
    configurable: false
  },
  name: {
    get: [Function: getter],
    set: [Function: setter],
    enumerable: false,
    configurable: false
  },
  message: {
    value: '',
    writable: false,
    enumerable: false,
    configurable: false
  },
  toString: {
    value: [Function: toString],
    writable: false,
    enumerable: false,
    configurable: false
  }
}
  • moderate (default):
{
  constructor: { get: {}, set: {}, enumerable: false, configurable: false },
  name: { get: {}, set: {}, enumerable: false, configurable: false },
  message: { get: {}, set: {}, enumerable: false, configurable: false },
  toString: { get: {}, set: {}, enumerable: false, configurable: false }
}
  • severe:
Object <[Object: null prototype] {}> {
  constructor: Object <[Object: null prototype] {}> {
    get: [Function: getter] Function <Function <Complex prototype>>,
    set: [Function: setter] Function <Function <Complex prototype>>,
    enumerable: false,
    configurable: false
  },
  name: Object <[Object: null prototype] {}> {
    get: [Function: getter] Function <Function <Complex prototype>>,
    set: [Function: setter] Function <Function <Complex prototype>>,
    enumerable: false,
    configurable: false
  },
  message: Object <[Object: null prototype] {}> {
    get: [Function: getter] Function <Function <Complex prototype>>,
    set: [Function: setter] Function <Function <Complex prototype>>,
    enumerable: false,
    configurable: false
  },
  toString: Object <[Object: null prototype] {}> {
    get: [Function: getter] Function <Function <Complex prototype>>,
    set: [Function: setter] Function <Function <Complex prototype>>,
    enumerable: false,
    configurable: false
  }
}

@kumavis
Copy link
Member Author

kumavis commented Nov 30, 2021

first '%ErrorPrototype%': { constructor: true } breaks the logging of errors
adding '%ObjectPrototype%': { 'constructor': true } fixes the logging of errors

@kumavis
Copy link
Member Author

kumavis commented Dec 1, 2021

@kumavis
Copy link
Member Author

kumavis commented Dec 1, 2021

neat hack, if you add a constructor property on the Error instance, it will log correctly in node

Object.defineProperty(err, 'constructor', { value: Error })

@erights
Copy link
Contributor

erights commented Dec 1, 2021

See #636

Gudahtt added a commit to MetaMask/metamask-extension that referenced this issue Aug 5, 2022
There is a SES bug that results in errors print printed to the console
as `{}`[1]. The known workaround is to print the error stack rather
than printing the error directly. This affects our build script when it
is run with LavaMoat.

We used this workaround in one place in the build script already, but
not in the handler for task errors. We now use it in both places.

The workaround has been moved to a function that we can use throughout
the build script.

[1]: endojs/endo#944
Gudahtt added a commit to MetaMask/metamask-extension that referenced this issue Aug 5, 2022
There is a SES bug that results in errors being printed to the console
as `{}`[1]. The known workaround is to print the error stack rather
than printing the error directly. This affects our build script when it
is run with LavaMoat.

We used this workaround in one place in the build script already, but
not in the handler for task errors. We now use it in both places.

The workaround has been moved to a function that we can use throughout
the build script.

[1]: endojs/endo#944
Gudahtt added a commit to MetaMask/metamask-extension that referenced this issue Aug 5, 2022
There is a SES bug that results in errors being printed to the console
as `{}`[1]. The known workaround is to print the error stack rather
than printing the error directly. This affects our build script when it
is run with LavaMoat.

We used this workaround in one place in the build script already, but
not in the handler for task errors. We now use it in both places.

The workaround has been moved to a function that we can use throughout
the build script.

[1]: endojs/endo#944
Gudahtt added a commit to MetaMask/metamask-extension that referenced this issue Aug 6, 2022
There is a SES bug that results in errors being printed to the console
as `{}`[1]. The known workaround is to print the error stack rather
than printing the error directly. This affects our build script when it
is run with LavaMoat.

We used this workaround in one place in the build script already, but
not in the handler for task errors. We now use it in both places.

The workaround has been moved to a function that we can use throughout
the build script.

[1]: endojs/endo#944
@Anastasia1510

This comment was marked as duplicate.

@erights
Copy link
Contributor

erights commented Aug 7, 2022

Do you have a reason to turn on consoleTaming: 'unsafe'? Without it, do you see error stacks?

acria-dominik pushed a commit to acria-dominik/acriawallet-extension that referenced this issue Oct 13, 2022
There is a SES bug that results in errors being printed to the console
as `{}`[1]. The known workaround is to print the error stack rather
than printing the error directly. This affects our build script when it
is run with LavaMoat.

We used this workaround in one place in the build script already, but
not in the handler for task errors. We now use it in both places.

The workaround has been moved to a function that we can use throughout
the build script.

[1]: endojs/endo#944
@kriskowal kriskowal self-assigned this Jan 10, 2024
@kriskowal kriskowal added kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024 good first issue Good for newcomers kriskowal-just-do-it-2024-01 Tasks that kriskowal can close out quickly to clear weeds labels Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers kriskowal-just-do-it-2024-01 Tasks that kriskowal can close out quickly to clear weeds kriskowal-review-2024-01 Issues that kriskowal wants to bring to the attention of the team for review as of January, 2024
Projects
None yet
Development

No branches or pull requests

4 participants