Describe the bug
Opening the web viewer with a blank connection causes an error "Bad Request: IModel is not open for rpc". Naturally, blank connections do not have an iModel to interface with.
I think I tracked down where this error is coming from. It appears to be coming from the newly added syncSelectionScopeList function that was added as part of this PR#297. Specifically, in the getSelectionScopes call, the function iModel.getRpcProps is called. getRpcProps throws the error if the iModelConnection is closed (and blank connections are always closed).
My guess is that the fix is to add logic to not sync selection scopes when the connection is blank, but I see the PR was created to replicate behavior that was removed in 4.x and I'm unsure how the previous behavior treated blank connections.
To Reproduce
Steps to reproduce the behavior:
Go to this sandbox: viewer-blank-connection-sandbox. It is just the sandbox's Geometry Template sandbox with no modifications.
Export the sandbox to a local project. To export
a. Click the three dots in the top right of the sandbox and from the dropdown, choose the Export Sandbox option.
b. In the popup that appears, click the Sandbox Download is ready link in the bottom left. This will download the sandbox as a zipped folder.
Unzip the folder.
Navigate to the folder. Create a new app client (I recommend step 3 of the quick start for this) and a new iTwin (I recommend My iTwins for this). Supply your app client and iTwin in the .env file.
Run npm install.
Run npm run start.
Observe the error.
Expected behavior
Blank connections should not cause rpc errors to be thrown.
Screenshots
Desktop:
OS: Windows 11
Browser: Chrome
iTwin.js Version: Reproduced on @itwin/web-viewer-react: 4.2.0 & @itwin/viewer-react: 4.5.0.
Describe the bug Opening the web viewer with a blank connection causes an error "Bad Request: IModel is not open for rpc". Naturally, blank connections do not have an iModel to interface with.
I think I tracked down where this error is coming from. It appears to be coming from the newly added
syncSelectionScopeList
function that was added as part of this PR#297. Specifically, in thegetSelectionScopes
call, the functioniModel.getRpcProps
is called.getRpcProps
throws the error if the iModelConnection is closed (and blank connections are always closed).My guess is that the fix is to add logic to not sync selection scopes when the connection is blank, but I see the PR was created to replicate behavior that was removed in 4.x and I'm unsure how the previous behavior treated blank connections.
To Reproduce Steps to reproduce the behavior:
npm install
.npm run start
.Expected behavior Blank connections should not cause rpc errors to be thrown.
Screenshots![image](https://github.com/iTwin/viewer/assets/113918602/94eb475f-8e5b-4ef1-ae9e-ee99cb0e318c)
Desktop:
OS: Windows 11 Browser: Chrome iTwin.js Version: Reproduced on @itwin/web-viewer-react: 4.2.0 & @itwin/viewer-react: 4.5.0.