         # the getScrollInfo function below will return the sizing data about
         # the cm instance before the above css font-size change has been rendered.
         f = () =>
-            cm.refresh()
+            cm_refresh(cm)
             scroll_after = cm.getScrollInfo()
             x = (scroll_before.left / scroll_before.width) * scroll_after.width
             y = (((scroll_before.top+scroll_before.clientHeight/2) / scroll_before.height) * scroll_after.height) - scroll_after.clientHeight/2

        @hide_startup_message()
        @element.find(".webapp-editor-codemirror-content").show()
        for cm in @codemirrors()
            cm.refresh()

    hide_startup_message: () =>
        @element.find(".webapp-editor-codemirror-startup-message").hide()

        f         : (project_id, path, opts) -> codemirror_session_editor(project_id, path, opts)
        is_public : false



# See https://github.com/sagemathinc/cocalc/issues/3538
cm_refresh = (cm) ->
    if not cm?
        return
    try
        cm.refresh()
    catch err
        console.warn("cm refresh err", err)