matrix-org / matrix.to

A simple stateless privacy-protecting URL redirecting service for Matrix
http://matrix.to
Apache License 2.0
934 stars 201 forks source link

Empty page with "SyntaxError: expected expression, got '.'" on Firefox 60esr and Chromium 73 #193

Closed Lomanic closed 3 years ago

Lomanic commented 3 years ago

Describe the bug Matrix.to is broken on Firefox 60esr and all versions before 74 and Chromium 73 and all versions before 80, the page doesn't have any text.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://matrix.to/#/#matrix:matrix.org with Firefox 60esr (any version before 74, see below) or Chromium 73 (any version before 80, see below)
  2. You are only greeted with an empty page, just as if you were visiting https://matrix.to/images/background-1224593451.svg
  3. In the web console, the following error is raised
      SyntaxError: expected expression, got '.' 
      bundle-esm-3551970109.js:1:1314

    Expected behavior Page is properly displayed without issue

Desktop:

Desktop:

Additional context Matrix.to uses optional chaining (?.), only supported by 85.03% of browsers/users globally according to caniuse. Support in Firefox was introduced with Firefox 74.0 only released 2020-03-10. Support in Chrome/ium was introduced with Chromium 80 only released 2020-02-04.

The issue comes from the following beautified function in https://matrix.to/bundle-esm-3551970109.js

function s(...e) {
    const t = {};
    for (const i of e) {
        if ("string" != typeof i) throw new Error("Invalid enum value name" + i?.toString());
                                                                            // ^___ error raised here
        t[i] = i
    }
    return Object.freeze(t)
}

In my opinion, having a bundle and using these new functions negates the point of simplicity mentioned in the README. The matrix.to links were not broken before the redesign, and while a quite happy Matrix user for a few years now, having the links broken client-side gives a bad image to new potential users about the Matrix ecosystem.

There are basically two solutions for this:

  1. not using this kind of syntax
  2. transpiling with https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining

While it may be argued that a new version of Firefox ESR is available in Debian 9 repositories (though Mozilla is unfortunately removing a lot of things I use every few versions, so I am really reluctant about upgrading because of this), this is not the case for Chromium.

Unfortunately, there's a trend since last year about websites carelessly breaking client-side while this being completely avoidable (usually missing polyfills or worse using new syntax like here), privileging developers happiness to users usability, and it saddens me quite a bit to see Matrix in the same wagon while I am a big fan and proponent of it.

Lomanic commented 3 years ago

Fixed in a464254, https://matrix.to/#/#matrix:matrix.org is not broken anymore on Firefox 60esr and Chromium 73. Thanks @bwindels.