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

Revisiting: fix for loading module twice with different case on case insensitive FSes #38752

Open
jedwards1211 opened this issue May 21, 2021 · 0 comments
Labels
module Issues and PRs related to the module subsystem.

Comments

@jedwards1211
Copy link

jedwards1211 commented May 21, 2021

@isaacs said in #5702 that it's impossible to tell if two filenames with different case point to the same file or not.

However, on mac OS at least with a case-insensitive filesystem, fs.stat will give the same ino for the same filename with different case. So it's completely possible, unless ino is somehow unreliable on some OSes.

I just ran into this issue due to a typo and it was mega confusing and annoying. Maybe ino was unavailable in the 0.x days, but it seems like there's no reason not to fix this now.

Seems to me that ino should be the real cache key, and require.cache should actually be retrofitted to proxy to an underlying ino-keyed cache. (I assume this would avoid duplicate loading multiple hardlinks to the same file as well). delete require.cache[key] would only actually delete the module if key is the last remaining path for the underlying ino.

However, I do read that inodes on windows are...complicated...so someone feel free to shoot holes in this proposal.

@jedwards1211 jedwards1211 changed the title Revisiting: fix for loading module twice with different case Revisiting: fix for loading module twice with different case on case insensitive FSes May 21, 2021
@Ayase-252 Ayase-252 added the module Issues and PRs related to the module subsystem. label May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module Issues and PRs related to the module subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants