Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Assertion Error #741

Unanswered
acivitillo asked this question in Problem
Apr 17, 2022 · 3 comments · 4 replies
Discussion options

Migrating to 0.38.1 causes this error:

idom | INFO: 172.28.0.1:33542 - "GET /organizations HTTP/1.1" 307 Temporary Redirect
idom | INFO: 172.28.0.1:33542 - "GET /home HTTP/1.1" 200 OK
idom | INFO: 172.28.0.1:33542 - "GET /embedding_script.js HTTP/1.1" 200 OK
idom | ERROR: Exception in ASGI application
idom | Traceback (most recent call last):
idom | File "/usr/local/lib/python3.8/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 184, in run_asgi
idom | result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
idom | File "/usr/local/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
idom | return await self.app(scope, receive, send)
idom | File "/usr/local/lib/python3.8/site-packages/fastapi/applications.py", line 212, in __call__
idom | await super().__call__(scope, receive, send)
idom | File "/usr/local/lib/python3.8/site-packages/starlette/applications.py", line 112, in __call__
idom | await self.middleware_stack(scope, receive, send)
idom | File "/usr/local/lib/python3.8/site-packages/starlette/middleware/errors.py", line 146, in __call__
idom | await self.app(scope, receive, send)
idom | File "/usr/local/lib/python3.8/site-packages/starlette/middleware/sessions.py", line 77, in __call__
idom | await self.app(scope, receive, send_wrapper)
idom | File "/usr/local/lib/python3.8/site-packages/starlette/exceptions.py", line 58, in __call__
idom | await self.app(scope, receive, send)
idom | File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 656, in __call__
idom | await route.handle(scope, receive, send)
idom | File "/usr/local/lib/python3.8/site-packages/starlette/routing.py", line 408, in handle
idom | await self.app(scope, receive, send)
idom | File "/usr/local/lib/python3.8/site-packages/idom/backend/starlette.py", line 148, in spa_app
idom | return await static_files_app({**scope, "path": path}, receive, send)
idom | File "/usr/local/lib/python3.8/site-packages/starlette/staticfiles.py", line 86, in __call__
idom | assert scope["type"] == "http"
idom | AssertionError
You must be logged in to vote

Replies: 3 comments 4 replies

Comment options

My guess is that this is related to one of two things. Either an outdated client version, or it's related to routing changes that were made. Take a look at the changelog entry here: https://idom-docs.herokuapp.com/docs/about/changelog.html#v0-38-0-a2

You must be logged in to vote
0 replies
Comment options

OK I noticed the embedding script has also changed, but looking into the documentation, I think queryParams it's missing, I tried to add it but I get an Uncaught DOMException: An invalid or illegal string was specified from idom-client-react on line 9.

I will continue to work on this.

import {
 LayoutServerInfo,
 mountLayoutWithWebSocket,
} from "https://esm.sh/idom-client-react@0.38.0";
// queryParams
const queryParams = (() => {
 const reservedParams = new URLSearchParams();
 const userParams = new URLSearchParams(window.location.search);
 const reservedParamNames = ["noReconnect"];
 reservedParamNames.forEach((name) => {
 const value = userParams.get(name);
 if (value !== null) {
 reservedParams.append(name, userParams.get(name));
 userParams.delete(name);
 }
 });
 return {
 reserved: reservedParams,
 user: userParams,
 };
})();
const serverInfo = new LayoutServerInfo({
 host: document.location.hostname,
 port: document.location.port,
 path: "_idom",
 query: queryParams.user.toString(),
 secure: document.location.protocol == "https:",
});
console.log(serverInfo)
mountLayoutWithWebSocket(document.getElementById("idom-app"), serverInfo);
You must be logged in to vote
0 replies
Comment options

OK, reading through the IDOM javascript source code I could figure it out. There are a few mistake in the new docs embed js script. This is the correct script:

import {
 LayoutServerInfo,
 mountWithLayoutServer,
} from "https://esm.sh/idom-client-react@0.38.1";
const serverInfo = new LayoutServerInfo({
 host: document.location.hostname,
 port: document.location.port,
 path: "/_idom",
 //query: queryParams.user.toString(),
 secure: document.location.protocol == "https:",
});
mountWithLayoutServer(
 document.getElementById("idom-app"),
 serverInfo
);

most importantly path must start with a /, otherwise the websocket URL will be incorrect and give a type error.

You must be logged in to vote
4 replies
Comment options

IDOM core should probably handle preceding slashes automatically for convenience. At least, that's Conreq's approach for every user URL obtained from the user.

Comment options

Should be a pretty easy fix. Anyone want to write this up as an issue?

Comment options

Will do tomorrow. Not at my computer at the moment.

Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /