Skip to content

Print javascript stack trace #229

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

Merged
merged 5 commits into from
Nov 6, 2024

Conversation

CrescentonC
Copy link
Member

No description provided.

@LPTK
Copy link
Contributor

LPTK commented Nov 4, 2024

Ok it looks like stack traces are very unstable wrt NodeJS version, which is unsurprising. Could you make it so that they only show when there's an unexpected runtime error? (As in: none of :re, :fixme, and :todo is set.)

@CrescentonC
Copy link
Member Author

I have made the changes. Not sure if this is the best way to do this, but I just add a new parameter showStackTrace to the query function in ReplHost which controls the printing of stack traces.

@LPTK
Copy link
Contributor

LPTK commented Nov 4, 2024

Thanks. I see the CI is still mysteriously failing with the git diff while showing no patch... Like in the previous PR. I really have no idea why.

@CrescentonC
Copy link
Member Author

CrescentonC commented Nov 5, 2024

I managed to reproduce the behavior on my machine.

This behavior seems to be caused by how git diff-files works; git diff seems to behave as desired. Calling git status or git update-index --refresh before git diff-file also makes git diff-file to behave as desired on my machine.

Some related posts on stack overflow (thanks to Ruqing who helped me to look into this issue):
https://stackoverflow.com/questions/36367190/git-diff-files-output-changes-after-git-status
https://stackoverflow.com/questions/34807971/why-does-git-diff-index-head-result-change-for-touched-files-after-git-diff-or-g


Below is my terminal history showing how the problem is reproduced.

~/c/mlscript (hkmc2-print-stack-trace)> git diff-files --exit-code                                   # exit code 0
~/c/mlscript (hkmc2-print-stack-trace)> git status                                                   # no changes
On branch hkmc2-print-stack-trace
Your branch is up to date with 'anto/hkmc2-print-stack-trace'.

nothing to commit, working tree clean
~/c/mlscript (hkmc2-print-stack-trace)> echo x >> hkmc2/jvm/src/test/scala/hkmc2/ReplHost.scala      # add something
~/c/mlscript (hkmc2-print-stack-trace)> truncate -s-2 hkmc2/jvm/src/test/scala/hkmc2/ReplHost.scala  # undo the previous change
~/c/mlscript (hkmc2-print-stack-trace)> git diff-files --exit-code                                   # now `git diff-files --exit-code` exit with 1, although there is no change in the contents of any file
:100644 100644 d9ccf26c987c5e29e8cda92004077828c62d064e 0000000000000000000000000000000000000000 M      hkmc2/jvm/src/test/scala/hkmc2/ReplHost.scala
~/c/mlscript (hkmc2-print-stack-trace) [1]> git diff-files --exit-code -p                            # `git diff-files --exit-code -p` exit with 1, but do not show any diff
~/c/mlscript (hkmc2-print-stack-trace) [1]> git diff --exit-code -p                                  # `git diff --exit-code -p` exit with 0
~/c/mlscript (hkmc2-print-stack-trace)> git diff-files --exit-code -p                                # `git diff-files --exit-code -p` now also exit with 0
~/c/mlscript (hkmc2-print-stack-trace)> git status                                                   # `git status` shows no changes
On branch hkmc2-print-stack-trace
Your branch is up to date with 'anto/hkmc2-print-stack-trace'.

nothing to commit, working tree clean
~/c/mlscript (hkmc2-print-stack-trace)> echo x >> hkmc2/jvm/src/test/scala/hkmc2/ReplHost.scala      # add something
~/c/mlscript (hkmc2-print-stack-trace)> truncate -s-2 hkmc2/jvm/src/test/scala/hkmc2/ReplHost.scala  # and undo the change again
~/c/mlscript (hkmc2-print-stack-trace)> git status                                                   # execute `git status` first
On branch hkmc2-print-stack-trace
Your branch is up to date with 'anto/hkmc2-print-stack-trace'.

nothing to commit, working tree clean
~/c/mlscript (hkmc2-print-stack-trace)> git diff-files --exit-code -p                                # after `git status`, `git diff-files --exit-code -p` exit with 0
~/c/mlscript (hkmc2-print-stack-trace)> git --version
git version 2.39.5 (Apple Git-154)

@LPTK
Copy link
Contributor

LPTK commented Nov 5, 2024

Wow, thanks for looking into this! I wonder why this was never a problem before. I suppose the new diff-tests is overriding some files even though there are no actual changes.

So what do you suggest to fix it? Fixing the root issue could actually make more sense. Could you commit the fix in this PR?

@CrescentonC
Copy link
Member Author

Indeed I guess this was not a problem before because previous diff-tests will run git status at the directory containing test files so that git diff-files, which is executed after git status, can work as expected. The new test CompileTestRunner does not run git status, so git diff-files report spurious file changes.

For the fix I think although git diff works as expected on my machine, I cannot find clear documentation saying that it will never report spurious changes. So maybe it's better to run git update-index -q --really-refresh before git diff-files.

@LPTK
Copy link
Contributor

LPTK commented Nov 6, 2024

Thanks for the fixes!

@LPTK LPTK merged commit 63eddc1 into hkust-taco:hkmc2 Nov 6, 2024
1 check passed
@LPTK LPTK deleted the hkmc2-print-stack-trace branch November 6, 2024 05:29
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

Successfully merging this pull request may close these issues.

2 participants