mrcrmn / docc

A starter documentation theme for Gridsome. Featuring instant search, great navigation and a dark mode!

Home Page:https://docc-theme.netlify.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError when build

kuleyu opened this issue · comments

Hello, there is an error happened when building.

Error: TypeError: Cannot read property 'disconnect' of null

Details:

(node:1416) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'disconnect' of null
    at a.$route (assets/js/page--src-templates-markdown-page-vue.2361b1f1.js:589:21)
......
(node:1416) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1416) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Influence: almost none. the building process finished normally, and the site worked normally.


The disconnect seems from the file ./src/components/OnThisPage.vue, line 65: this.observer.disconnect();.

some solutions?

Just tried a fresh deploy and am getting the same issue. Any updates?

I solved this by moving this.observer.disconnect() and this.$nextTick(this.initObserver) into if (process.isClient).

IntersectionObserver is a browser API and should not be used during rendering.

watch: {
  $route: function () {
    if (process.isClient) {
      if (window.location.hash) this.activeAnchor = window.location.hash

      // Clear the current observer.
      this.observer.disconnect()

      // And create another one for the next page.
      this.$nextTick(this.initObserver)
    }
  }
}

@exuanbo Thanks, it's usefull.