Skip to content
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

Avoid double-reporting the filename in JS library errors/warnings #23787

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Feb 27, 2025

As part of this I also avoid converting JS libraries path to absolute paths where possible. This means that errors and warnings show the actual pathname passed by the users, and not some absolute path. This makes writing tests for the double-reporting issue easier, and makes the errors/warnings easier to read (IMHO).

@sbc100 sbc100 requested a review from kripken February 27, 2025 23:25
@sbc100 sbc100 force-pushed the js_warnings_part2 branch 2 times, most recently from 02a9d6f to a440409 Compare February 27, 2025 23:48
As part of this I also avoid converting JS libraries path to absolute
paths where possible.  This means that errors and warnings show the
actual pathname passed by the users, and not some absolute path.  This
makes writing tests for the double-reporting issue easier, and makes the
errors/warnings easier to read (IMHO).
jslib = utils.path_from_root('src/lib', jslib)
system_lib = utils.path_from_root('src/lib', jslib)
if os.path.exists(system_lib):
jslib = system_lib
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this condition mean that a js library with the same basename as a system one will behave differently than before?

Copy link
Collaborator Author

@sbc100 sbc100 Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this actually fixes a bug here the lookup/resolution used by get_js_sym_info was different to the lookup/resolution used in src/modules.mjs:

The two codepaths now have the same logic, which is good.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JS always had (!path.isAbsolute(filename) && fs.existsSync(path.join(systemLibdir, filename)) as the condition.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Can we add a test for the bugfix?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man, that would be a very subtle bug to write a fix for. I can give it a go but I'm not sure its worth it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I'm not sure its possible since all --js-library args were processed as os.path.abspath below, so I guess we can consider it an inconsistency/bug that was not previously exposed in any way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But maybe there is an edge case where for when the user specifies the name of a js-library that happens to match a system library. I'll write test for that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's complex to test than I agree it's not worth it. I was hoping it was simple...

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