Skip to content

Commit 2c823db

Browse files
Fix non-working comms when viewing a notebook with old WebIO content
1 parent 8dbdee8 commit 2c823db

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/providers/ijulia.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ function main()
7575
@warn "IJulia doesn't have register_mime; WebIO may not work as expected. Please upgrade to IJulia v1.13.0 or greater."
7676
end
7777

78+
# Delete any old comms before displaying the first WEBIO_NODE_MIME content (which prompts a new connection)
79+
# Reason: If a freshly opened notebook has previously rendered WEBIO_NODE_MIME, an old comm is
80+
# (incorrectly) registered from/by jupyter before WebIO has been init'ed
81+
for (k,v) in IJulia.CommManager.comms
82+
if IJulia.CommManager.comm_target(v) == :webio_comm
83+
IJulia.CommManager.close_comm(v)
84+
delete!(IJulia.CommManager.comms, k)
85+
end
86+
end
87+
7888
# See comment on _IJuliaInit for what this does
7989
display(_IJuliaInit())
8090
end

0 commit comments

Comments
 (0)