-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Console doesn't print current variable content for Object types (bug in console-feed
)
#1203
Comments
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already. |
thanks for reporting! what a strange bug. not sure what's going on here! |
I have the feeling that it is somehow related to the fact that javascript works asynchronously. While the print function is preparing the output the programm goes on and starts to sort the content of the array. At some point ,while the sorting process is still in progress, the print function comes back and catches the data of array, which is now partly sorted. |
I think you're right! I was trying to demonstrate to a student yesterday how Arrays work (vs primitive types in JS) and came across the same bug. Here's an example sketch that demonstrates it. |
A potentially similar issue was reported on main p5.js repo. The exact same code worked correctly on codepen.io and incorrectly in the p5 Editor. |
Print outputs are correct in the Chrome console (78.0.3904.87). In case it helps narrow down the issue: wrapping the array value change in a 1ms timeOut gives correct outputs. Example |
hehe "vile but correct". thanks for figuring that out, that's super helpful! |
The Problem here is array is a reference type object so when we are doing console.log(arr) it is actually showing content from the prototype of that array i dont know why this is happening like this can be a problem with how arrays or console.log are looked in the by web editor compiler. this sketch code can help you understand the problem better |
This is a problem with the library "console-feed" even codesandbox and other users of this library has this problems. |
@catarak I think this issue can be closed for now or if somebody can suggest a better logging library(that doesn't has this problem) would solve this |
A possible solution is disabling serialization. |
It's very easy to run into this bug when trying to explain array mutation to new programmers. Here's a screenshot showing some code, the web-editor console, and the browser console. You can clearly see the divergence between the web-editor console and browser console. @ashu8912 – I am not sure what the issue-closing policy is for this project, but I would appreciate keeping this issue open as long as the problem persists. (There are, after all, multiple possible fixes, including: fixing the bug in console-feed, using console-feed in a different way, switching away from console-feed.) Thanks! |
I think unfortunately this is an issue with |
console-feed
)
I've submitted a PR to |
I just checked this with the latest version of |
I'm checking now and I believe that it's working correctly for me, so I'm closing this for now! |
@raclim It's not working for me! Same behavior as my post in 2020. Are you getting something different? |
Hi @raclim, did you see #1203 (comment)? I don't want this issue to get lost if it hasn't actually been fixed! Thanks. |
Ping on this, @raclim. Or please let me know if I should stop bothering you. 🙏 |
I'm so sorry @joshuahhh for not seeing these!!! I think your pings ended up getting lost a while back 😭 You're correct that it actually hasn't been resolved. I'm going to reopen this and try to see if a workaround could be found! |
Nature of issue?
Details about the bug:
Google Chrome | 77.0.3865.120 (Offizieller Build) (64-Bit) (cohort: Stable)
Windows
Run the Programm and load ergebnisse.txt
copy:
Otto, 345
Klaus, 23454
Leonie, 234
to ergebnisse.txt file
Run: https://editor.p5js.org/ZIM/sketches/6NUFu7ELU
Load ergebnisse.txt
Open Chrome developer Console.
Chrome developer Console shows different Values (the right ones) of an Arrays compared to p5js Web Editor Console. (Compare 9th and 10th line of output of p5js
web editor Console)
Feature enhancement details:
New feature details:
The text was updated successfully, but these errors were encountered: