-
Notifications
You must be signed in to change notification settings - Fork 44
Cache system mismatch with web #62
Comments
With who? Links? References? |
private chats while I tried to reread spec and a blurb on https://freenode.logbot.info/whatwg/20180411#c1498394 that had some other private chats around it. |
I realize this is a difference, but is there an actual impact on users caused by this? |
I'm with @benjamingr here. Since redirects aren't really symlinks and the whatwg doesn't cover file system symlink behavior (does it?) isn't this an unspecified space? |
@benjamingr this has a few things going on here that kind of led to why #60 exists and a difference in how @jdalton this is relevant if there is to ever be This is mostly relevant for ecosystem mismatch and lack of existing behavior like this in the wild. Figured an issue would be good to gather data and see if any existing ESM plans/tools/etc. outside of the web are doing this. |
@bmeck thanks, that example completely explains the issue - maybe present it at the meeting today? I don't think this is a huge deal given symlinks aren't redirects (and a server serving a symlinked file won't respond with a redirect anyway). What if we just make the module loader cache alias symlink destinations to the URL which would reinstate the "singleton" guarantee? That should be allowed by the spec right? |
@benjamingr HTTP redirects are part of https://github.com/WICG/webpackage 's archive format and also used for some things where you don't have CORS so you make a pass through endpoint. Being unable to use WebPackage to bundle up the file system would be a bit of a snag in plans. I've got to bad of a cough due to being sick to really present anything today and on vacation starting Friday til end of month. IDK when / who can take a look at all of this.
Not sure I understand? To which URL? |
That 👆. It's good to be aware of browser's behaviors here if ever Node adopts http(s) requests for imports (a tough hill) but I don't think it affects the current file system behaviors of Node as symlinks and redirects are not the same thing. |
We should look at this more seriously than saying the mental models aren't related. The underlying technology is less important to me than the mental mismatch of if the cache key is based upon the request or the destination, and which the resolution is based on. |
So if one day WHATWG specs symlinks AND it doesn't match. That's a lot of WHAT-IFs. It still doesn't change the fact that symlinks are not the same thing as redirects. If anything this just means those representing Node need to pound the pavement raising awareness of how Node handles such things so when and if folks in the WHATWG start to look around for references they have clear info to draw from.
As I said it's good to know but for sure but symlinks and redirects are different things. There is no need to mush them into the same box. |
@jdalton even if we remove symlinks they are cacheing the modules using a different specifier->key model than we are. We don't need to focus on the symlinks but more the model differences and the problems that causes for compatibility.
This has not historically been successful when I've talked to people about things, often have seen "well, I don't know why Node would do that" or "that is Node's problem" sort of reply as a dismissal which ends the discussion. I don't have your optimism given my experiences. |
To note this is somewhat brought up in the past as well by @guybedford in whatwg/html#613 but was in a different perspective and still discussing the now unused https://github.com/whatwg/loader . A similar way to prevent the mismatch from existing as described in that issue could be done if Node were to error on traversing symlinks during resolution which is probably a non-starter. |
Working through what the kernel of the concern is, is a good thing. That said I expect caching approaches to be different for different things (symlinks, redirects, etc.). If there is overlap then those areas should be examined.
We are pretty different.
If we are to move away from symlinks as the example can you rephrase/reframe the concern without them to better highlight the mismatch. |
@jdalton the mental model only shows up with a concrete mismatch when a redirect and symlink are compared. I can't remove them because I need a layer of indirection to occur. You need the indirection in the examples (both on web using HTTP redirect, and Node using symlinks) to differentiate if the cache is using the request URL or the response URL. I might be able to think of a mismatch using |
@bmeck, question: what is the import.meta.url in the four cases you
described? I believe it's already implemented in Chrome, and am not sure
whether it's already in Node.
|
@giltayar It is implemented in Chrome and Safari (they differ though slightly) but does not match expectation of people who expected it to be related to the cache key used (I thought it was supposed to be tied to cache key when I discussed it last). Without it being tied to cache key it serves a very different purpose than what is is starting to be used for and is not unique.
Note that in the Web Note that there is an open issue about explicitly censoring URL fragments from being available on |
If given that
and then
we are back to symlinks and redirects are entirely different things so there is no mismatch since there is no match to begin with (apples and oranges). What you're highlighting is, yes there is a difference because, in fact, they are different things. |
@jdalton fine here is one using a package.json since you are so insistent on claiming this is about symlinks. Maybe we can try to discuss the differences in how they work and workflows using them rather than repeatedly stating that different technologies are different from each other. This has slightly different results due to package.json not being like a symlink for
|
I was asking if you could produce an example without symlinks since you had stated the problem could be shown without them.
What you're showing is that redirects behave differently than symlinks again. Yes, they totally do and that's fine since they are totally different. |
@jdalton the |
The table in the summary below it does though, so it's unclear what you're trying to illustrate. |
@jdalton the |
I'm still not seeing the issue here. You've highlighted that the web does a Thing A differently than Node does a Thing B. If the issue was the web does Thing A differently than Node does Thing A I could see the problem for sure. |
@jdalton the concern is that Thing A and Thing B differ in usage patterns that they are not suitable to converge over time. |
Correct, they are totally different and not likely to converge. I think identifying it is good, and classifying it as such is fine. |
Noted, I think we need to have a more in depth discussion though. |
Looking at this, makes me think a bit more about Node's choice of realpath vs. symlink. I believe the reason that Node has the two modes is that none of them are satisfactory. The fact that there are symlinks is usually The web is adopting something that is different than both of them, and it got me thinking if maybe ESM should adopt a model that combines the advantages of both. Let's call this mode "mixed". In this mode, the module key map of the imported module will be the realpath, while the module resolution path of this module will be the symlink path. This enables us to have the advantages of both: we both have the module as a singleton, and yet it participates in the "natural" module resolution of the importing module. Doing this change in CJS is obviously not going to happen, but maybe ESM is a time for a change. Hope I was clear enough. This is a hairy issue. |
@giltayar I have some concerns with the web approach. In particular you get into some situations where things seem unintuitive to myself at least:
Creates 2 module records even though
|
@bmeck, my suggestion uses the realpath as a cache key, but change the module resolution algorithm to use the symlink. It's an idea I had, which is admittedly only tangentially related to this issue. I believe the idea nicely solves the problems people have with But maybe I should just try out the idea, and just create a PR for it if it turns out to be practical and useful... |
Did a bunch of digging after #60 showed up. Didn't realize some cache mismatching mental models with how web works and how existing tooling and algorithms work until I reviewed.
As currently specced for web given:
For Node we can treat the redirects as symlinks.
Loads 3 module records, which means it does not match current ESM loader, nor
--preserve-symlinks
. Almost all tooling is written to CJS style realpathing but has a--preserve-symlinks
compatible flag. These 3 (web, realpath [node default], symlinks [--preserve-symlinks
]) modes have the following loads according to WHATWG upon review and consultation:/a1.mjs
/a1.mjs
/b/c/d.mjs
/a1.mjs
/a2.mjs
/a2.mjs
/b/c/d.mjs
/a2.mjs
./e.mjs
from/a1.mjs
/b/c/e.mjs
/b/c/e.mjs
/a1/c/e.mjs
./e.mjs
from/a2.mjs
/b/c/e.mjs
/b/c/e.mjs
/a2/c/e.mjs
Notably, the imports in current web spec are keyed before realpathing/redirecting for the module map (like
--preserve-symlinks
), but the resolves import specifiers as done post realpathing/redirecting (like default Node behavior).This affects mismatch is in all build tools that I know of ??? Does anyone know of any build tooling that does this type of resolution, even if it requires configuration to do so?
We should look into this, it looks like web spec won't change it looks like after some talking. They seem to see it as a 2.5-3 year old issue and time to discuss likely won't change decisions :-/
The text was updated successfully, but these errors were encountered: