Skip to content

Console messages appear twice #141

@hinzundcode

Description

@hinzundcode

When running my script the first time I get one log message, but as I run it again I get two messages, the old log and the new log. What am I doing wrong?

versions:
Google Chrome 59.0.3071.71 beta
chrome-remote-interface@0.23.0

my script:

"use strict";
const chrome = require("chrome-remote-interface");

(async () => {
	chrome(async protocol => {
		const { Page, Console } = protocol;
		
		Console.messageAdded(({ message }) => {
			console.log(message);
		});
		
		await Promise.all([
			Page.enable(),
			Console.enable(),
		]);
		
		await Page.navigate({ url: "http://127.0.0.1:8081/index.html" });
		await Page.loadEventFired();
		
		protocol.close();
	}).on("error", e => console.log(e));
})().catch(e => console.log(e));

the example page:

<!DOCTYPE html>
<script>console.log("hi")</script>

console output:

{ source: 'console-api',
  level: 'log',
  text: 'hi',
  url: 'http://127.0.0.1:8081/index.html',
  line: 2,
  column: 17 }
{ source: 'console-api',
  level: 'log',
  text: 'hi',
  url: 'http://127.0.0.1:8081/index.html',
  line: 2,
  column: 17 }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions