Skip to content

console history is not cleared between requests #625

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

Closed
zetachang opened this issue Oct 27, 2016 · 3 comments
Closed

console history is not cleared between requests #625

zetachang opened this issue Oct 27, 2016 · 3 comments
Milestone

Comments

@zetachang
Copy link

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
@rmosolgo
Copy link
Member

In general, I think reusing a a context is OK, otherwise, you pay overhead for starting up a new one every time.

Maybe it's time to dust off #559

@zetachang
Copy link
Author

Yeah, agreed on the overhead to start up new one every time, but at least we could clear up console, global, window.. ?

@rmosolgo
Copy link
Member

Addressed in #692, will be fixed in 2.0.0

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

No branches or pull requests

2 participants