-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix rendering on JupyterHub 4.1: respect absolute_url
for protocol determination, support data-absolute-url
#14003
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## branch-3.6 #14003 +/- ##
=============================================
Coverage ? 93.11%
=============================================
Files ? 281
Lines ? 19828
Branches ? 0
=============================================
Hits ? 18462
Misses ? 1366
Partials ? 0 |
bokehjs/src/lib/embed/server.ts
Outdated
if (absolute_url === undefined && frameElement !== null && (frameElement as HTMLIFrameElement).dataset.absoluteUrl !== undefined) { | ||
absolute_url = (frameElement as HTMLIFrameElement).dataset.absoluteUrl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove all this casting with:
if (absolute_url === undefined && frameElement !== null && (frameElement as HTMLIFrameElement).dataset.absoluteUrl !== undefined) { | |
absolute_url = (frameElement as HTMLIFrameElement).dataset.absoluteUrl | |
if (absolute_url === undefined && frameElement instanceof HTMLElement && frameElement.dataset.absoluteUrl !== undefined) { | |
absolute_url = frameElement.dataset.absoluteUrl | |
} |
or alternatively use HTMLIFrameElement
instead of HTMLElement
, though I'm not sure if we need to be that specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking was the same here! But it does not work. This is because frameElement
is an HTMLElement
, but not window.HTMLElement
. It is an HTMLElement
from the context of the parent frame. I can make this work without type cast by checking for the right instance - which is just a bit more code - but frameElement
by definition is an HTMLElement
("element" is in the name).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you still think I should modify it here or do you agree with the type cast here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, using frameElement instanceof window.parent.HTMLElement
can result in:
DOMException: Failed to read a named property 'HTMLElement' from 'Window': Blocked a frame with origin "http://localhost:5151" from accessing a cross-origin frame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in c639a85
Co-authored-by: Mateusz Paprocki <[email protected]>
We need to be able to test this somehow, preferably outside of jupyter. Perhaps an example showing |
@mattpap thank you for your review (dziękuję!) - I've added an example which both demonstrates the problem and a solution under I also added a dedicated type guard to remove the explicit type cast (I do not like them either!). |
|
Thank you @bryevdv, I moved it to |
@mattpap will have to comment on the test screenshot error
|
Looking at: Lines 18 to 31 in 54252f8
It seems that similar examples (e.g. examples |
Let's just go with that option for now |
It did not help. I think this is because the top-level file is not an example of Bokeh server with a single handler, but a flask application which embeds code which connects to the server running in a subprocess. I am not sure how to proceed, possibly moving it elsewhere would be better. If a maintainer would prefer to rehash it please do push to my branch. |
Sorry, I was wrong it did help, another job failed which appears unrelated. I will restart CI by pushing an empty commit to see if it helps. |
Previously |
Yes there is one server test that probably ought to get a retry policy or similar. |
@krassowski I really appreciate your patience, I have one more request. After thinking about it, I would prefer this live under |
@bryevdv make sense - done, and it looks all tests passed! |
Thanks @krassowski ! |
Amazing, thank you! Is there a chance for backporting this PR or will it be only available in 3.6? |
It seems like it would be easy to backport, so I have added the label. However, that just means that if there is a new release on previous branches, then this is a candidate to go in it. It's reasonably likely there will end up being more earlier point releases, but I can't guarantee it. Edit: though looking at other PRs marked for backport, it seems fairly like there will be at some point. |
…determination, support `data-absolute-url` (#14003) * Fix rendering on JupyterHub 4.1 * Get rid of the mutable variable Co-authored-by: Mateusz Paprocki <[email protected]> * Add an example * Do not use type casting, define a custom type guard * Reduce size of the negative example iframe * Lint * Move to `app/iframe_embed` * Skip `iframe_embed` for now * Retrigger CI * Move to `examples/server/api` --------- Co-authored-by: Mateusz Paprocki <[email protected]>
@krassowski this fix is available now in 3.5.2 |
…determination, support `data-absolute-url` (bokeh#14003) * Fix rendering on JupyterHub 4.1 * Get rid of the mutable variable Co-authored-by: Mateusz Paprocki <[email protected]> * Add an example * Do not use type casting, define a custom type guard * Reduce size of the negative example iframe * Lint * Move to `app/iframe_embed` * Skip `iframe_embed` for now * Retrigger CI * Move to `examples/server/api` --------- Co-authored-by: Mateusz Paprocki <[email protected]>
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
srcdoc
iframe #14002This PR:
ws
/wss
determination whenabsolute_url
is passeddata-absolute-url
of an iframe assrcdoc
iframes cannot pass it otherwise (e.g. there is no motion of URL parameters for these)How to test without installing JupyterHub
jupyter --paths
and choose a writable config path from theconfig:
section, e.g./home/username/my-env/etc/jupyter
/home/username/my-env/etc/jupyter/jupyter_server_config.py
, paste the following:jupyter lab
hubPrefix
by viewing the source of JupyterLab page