Skip to content

Runtime.CompileScript throws an error on a long input script #4

Description

@yarikbratashchuk

Hello again)

I'm trying to run a script with Runtime.RunScript.
Script itself is about 13000loc.

First i do Runtime.CompileScript and then i do Runtime.RunScript
But it always fails on Runtime.CompileScript, error message differs from time to time:

  • cdp.Runtime: CompileScript: write tcp 127.0.0.1:65367->127.0.0.1:9222: use of closed network connection
  • cdp.Runtime: CompileScript: rpcc: the connection is closing
  • cdp.Runtime: CompileScript: websocket: close 1006 (abnormal closure): unexpected EOF

i tried to run Runtime.CompileScript and Runtime.RunScript with short script that returns promise, and it works fine.
Is there any restriction for the script size? Or maybe there is another way to run such long script?

this is how it looks in code

exp, err := ioutil.ReadFile("./content.js")
if err != nil {
	panic(err)
}
if err := c.Runtime.Enable(ctx); err != nil {
	panic(err)
}
compileReply, err := c.Runtime.CompileScript(context.Background(), &cdpcmd.RuntimeCompileScriptArgs{Expression: string(exp), PersistScript: true})
if err != nil {
        // it panics all the time for a 13000loc script
	panic(err)
}
awaitPromise := true
runReply, err := c.Runtime.RunScript(ctx, &cdpcmd.RuntimeRunScriptArgs{ScriptID: *compileReply.ScriptID, AwaitPromise: &awaitPromise})
if err != nil {
	panic(err)
}

Sincerely, yarik

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions