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

format null prototyped object throw unexpected error #166

Closed
await-ovo opened this issue Oct 8, 2022 · 0 comments · Fixed by #167
Closed

format null prototyped object throw unexpected error #166

await-ovo opened this issue Oct 8, 2022 · 0 comments · Fixed by #167

Comments

@await-ovo
Copy link
Contributor

Step to reproduce:

  1. write code as below in index.mjs:
// index.mjs
import { EdgeRuntime } from 'edge-runtime'
const main = async () => {
  try {
    const runtime = new EdgeRuntime();
    runtime.evaluate(`
      const a  = Object.create({})
      console.log('a --> ', a);
      const b  = Object.create(null)
      console.log('b --> ', b);
    `);
  } catch(err) {
    console.log(`evaluate error: `, err);
  }
}
main();
  1. executing node ./index.mjs, you can see the error in terminal:
evaluate error:  evalmachine.<anonymous>:124
    var getConstructorName = /* @__PURE__ */ __name((object) => object.constructor.name, "getConstructorName");
                                                                                   
TypeError: Cannot read properties of undefined (reading 'name')
    at getConstructorName (evalmachine.<anonymous>:124:84)
    at formatRaw (evalmachine.<anonymous>:229:29)
    at formatValue (evalmachine.<anonymous>:224:16)
    at inspect (evalmachine.<anonymous>:346:16)
    at format (evalmachine.<anonymous>:196:26)
    at Object.log (evalmachine.<anonymous>:571:55)
    at evalmachine.<anonymous>:5:15

Expected

console.log should work successfully on objects with null prototype as it does in the browser.

Environments

  • node: v16.15.1
  • edge-runtime: 1.1.0-beta.31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant