Skip to content

Runtime.evaluate throws error even when there is no side effects.  #22571

@antsmartian

Description

@antsmartian

Hello Everyone,

I was just trying to play around with inspector and noticed we have a bug in version : v10.5.0. Here is the sample code:

const inspector = require('inspector');

const session = new inspector.Session();
session.connect();
session.post('Runtime.evaluate',{
    expression : '[1,0,5].sort()',
    generatePreview: true,
    throwOnSideEffect: true,
}, (error, { result }) => console.log(result));

Running this code on version 10.5.0 gives me back:

{ type: 'object',
  subtype: 'error',
  className: 'EvalError',
  description:
   'EvalError: Possible side-effect in debug-evaluate\n    at Session.post (inspector.js:85:28)\n    at Object.<anonymous> (/Users/anto/programs/node/repl/src/test.js:9:9)\n    at Module._compile (internal/modules/cjs/loader.js:702:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)\n    at Module.load (internal/modules/cjs/loader.js:612:32)\n    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)\n    at Function.Module._load (internal/modules/cjs/loader.js:543:3)\n    at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)\n    at startup (internal/bootstrap/node.js:240:19)\n    at bootstrapNodeJSCore (internal/bootstrap/node.js:564:3)',
  objectId: '{"injectedScriptId":1,"id":1}' }

which seems to be wrong. Since the expression [1,0,5].sort() doesn't have any side effects. The same code works on the current version (i.e 10.9.0). Gives the output:

{ type: 'object',
  subtype: 'array',
  className: 'Array',
  description: 'Array(3)',
  objectId: '{"injectedScriptId":1,"id":1}',
  preview: 
   { type: 'object',
     subtype: 'array',
     description: 'Array(3)',
     overflow: false,
     properties: [ [Object], [Object], [Object] ] } }

May be an issue in v8? Thanks for looking into this.

Edit:

Just checked it's even working in v10.0.0.

Metadata

Metadata

Assignees

No one assigned

    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