Skip to content

console history is not cleared between requests #625

@zetachang

Description

@zetachang

My app doesn't crash, but I'm getting unexpected behavior. So, I've described the unexpected behavior and suggested a new behavior.


console.history is not cleared when used with prerender method using therubyracer runtime.

Here is an example extracted from the sprockets_renderer_test

@renderer.render("TodoListWithConsoleLog", {todos: ["log some messages"]}, nil)
puts @renderer.render("TodoListWithConsoleLog", {todos: ["log some messages"]}, nil)

will result to

<ul data-reactroot="" data-reactid="1" data-react-checksum="-1309656939"><li data-reactid="2">Console Logged</li><li id="status" data-reactid="3">yep</li><li data-reactid="4">log some messages</li></ul>
<script>
console.log.apply(console, ["got initial state"]);
console.warn.apply(console, ["mounted component"]);
console.error.apply(console, ["rendered!","foo"]);
console.log.apply(console, ["got initial state"]);
console.warn.apply(console, ["mounted component"]);
console.error.apply(console, ["rendered!","foo"]);
</script>

The rubyracer v8_context deep inside is the same during multiple evals, and so is other stuff user might stored in global.

This is not happened in the default execjs runtime given that it shell out every time eval invoked.

Test environment

  • react-rails: master
  • therubyracer: 0.12.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions