Open naglepuff opened 1 month ago
@zachmullen @manthey I'd like input from you both regarding b691b9a, since I feel like I'm missing some context about some of the changes made - both in girder/girder v5, and in the current HistomicsUI code base.
The commit mentioned above wraps some code in an event handler to delay it running until girder.rest.getApiRoot()
will return a real (i.e. not undefined
) value. The wrapped code was introduced in PR #429. This code calls HuiSettings.getSettings
, which in turn calls girder.rest.restRequest
, which calls getApiRoot
when building the URL for the rest request.
The issue I was seeing in the girder 5 version of the stack was that at the time this code ran (it's a top-level function in the file, so I believe it would run whenever it was imported), getApiRoot
returns undefined
.
I spoke with @manthey and then compared Girder 3 and Girder 5's rest.js
code. It looks like in v3, there's additional code that sets apiRoot
directly in rest.js
(either pulling a value out of an HTML tag with jquery, or using a default value). See here. This code is not present in the v4-integration
branch, and I'm not sure exactly why it was removed.
Girder does call setApiRoot
during the initialization process, but that is async, so my best guess is that code in HistomicsUI is being run before the Girder app has finished initializing (and specifically, before it has got to this point). In that sense, I think wrapping the code in an event handler makes sense.
If my understanding of things is correct, then there is a difference between Girder 3 and Girder 5 in that plugins being developed for Girder 3 could make restRequest
s before the Girder app itself had finished initializing, and in Girder 5, plugins can no longer make that assumption.
Maybe this is a side-effect of getting rid of the build
command, or not, I'm not so sure. But if there are plugins that will break due to this difference maybe this is worth documenting in the migration guide? Am I off base here @zachmullen?
This code is not present in the v4-integration branch, and I'm not sure exactly why it was removed.
In Girder 3, the SPA code was loaded into a page that was server-rendered and included some relevant values inside of the HTML. In Girder 5, that went away; any such relevant values are now baked directly into the SPA static bundle at build time. In Girder 5, the HTML is a normal vite build target index.html, and the server no longer renders any HTML itself.
Bring the
girder-5
branch up to date with changes frommaster