toeverything / AFFiNE

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
https://affine.pro
Other
41.79k stars 2.73k forks source link

​Blank screen when refresh page or enter page with link #8639

Open xuhao1 opened 2 days ago

xuhao1 commented 2 days ago

What happened?

When refreshing page or enter page with link on self host on version canary-ff95f12, the page will become blank, and it shows image

Distribution version

macOS ARM 64 (Apple Silicon)

What browsers are you seeing the problem on if you're using web version?

No response

Are you self-hosting?

Relevant log output

No response

Anything else?

No response

ZhunCn commented 2 days ago

I'm having the same issue. When I look at the raw html that is served, I see this:

<script src="localhost/js/runtime.f74c6a32.js"></script>
<script src="localhost/js/npm-blocksuite.e2e1adb4.js"></script>
<script src="localhost/js/npm-rxjs.82521c3f.js"></script>
<script src="localhost/js/npm-emotion.66a3d116.js"></script>
<script src="localhost/js/npm-react.faf1d5e6.js"></script>
<script src="localhost/js/npm-jotai.4f5cdadc.js"></script>
<script src="localhost/js/vendor.fdf9528d.js"></script>
<script src="localhost/js/9797.04015564.js"></script>
<script src="localhost/js/3598.0300d0b6.js"></script>
<script src="localhost/js/app.1633087b.js"></script>

I think it may be a bug introduced from here: https://github.com/toeverything/AFFiNE/pull/8460/files#diff-0d69d237ea3cf29d027596ee870bf1e8e1bdf0103fa36dd584cf35871e47c642R231

  /**
   * Should only be called at startup time
   */
  private readHtmlAssets(path: string): HtmlAssets {
    const manifestPath = join(path, 'assets-manifest.json');

    try {
      const assets: HtmlAssets = JSON.parse(
        readFileSync(manifestPath, 'utf-8')
      );

      const publicPath = this.config.isSelfhosted
        ? this.config.server.host + '/'
        : assets.publicPath;

      assets.publicPath = publicPath;
      assets.js = assets.js.map(path => publicPath + path);
      assets.css = assets.css.map(path => publicPath + path);

      return assets;
    } catch (e) {
      if (this.config.node.prod) {
        throw e;
      } else {
        return defaultAssets;
      }
    }
  }

The isSelfhosted variable may not be set correctly and returning the wrong values for the path.

ZhunCn commented 14 hours ago

Looks like the #8660 PR fixed the issue for me.