sagemathinc / cocalc

CoCalc: Collaborative Calculation in the Cloud
https://CoCalc.com
Other
1.17k stars 216 forks source link

crash on home page when project not running #6859

Open haraldschilly opened 1 year ago

haraldschilly commented 1 year ago

Opened a sagews file as a "normal user", project wasn't running, and when opening the "home page" of the project, I saw this stack trace.

Screenshot from 2023-08-08 09-28-36

The part in the code is here, pointy brackets indicate the location.

        function u(e) {
            var t = !0
              , n = !1
              , r = void 0;
            try {
                for (var i, o = e[Symbol.iterator](); !(t = (i = o.next()).done); t = !0) {
                    var a = i.value;
                    a.content && a.content.includes(s) && (a.content = a.content.replace(c, ""),
                    null != a.children && u(a.children))
                }
            } catch (e) {
                n = !0,
                r = e
            } finally {
                try {
                    t || null == o.return || o.return()
                } finally {
                    if (n)
                        throw r
                }
            }
        }
        function d(e, t) {
            var n = void 0;
            if (e = function(e) {
                return e.replace(/^(```+)\s+$/gm, "$1") <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            }(e),
            !t) {
                var i = (0,
                r.parseHeader)(e);
                e = i.body,
                n = i.header
            }
            var o = e.split("\n");
            e = function(e) {
                return e.replace(/(?:\S)\ $/gm, (function(e) {
                    return e[0] + l
                }
                ))
            }(e);
            var a = {}
              , s = r.markdown_it.parse(e, a);
            return u(s),
            {
                tokens: s,
                meta: n,
                lines: o,
                references: a.references
            }
        }
haraldschilly commented 1 year ago

Ohh, I got it, this happens when you try to open a file of another user, where you do not have access. Well, the take away is the UI should clearly say to the user, that he or she has no access ... instead of crashing in weird ways.

williamstein commented 1 year ago

Coincidentally, I just fixed an issue that probably led to you getting into a situation where this (="open a file of another user, where you do not have access.") could happen: https://github.com/sagemathinc/cocalc/commit/498e14a067768d12acfe295f8e76875a08b08ffa