cube-js / cube

📊 Cube — Universal semantic layer platform for AI, BI, spreadsheets, and embedded analytics
https://cube.dev
Other
18.01k stars 1.78k forks source link

Cannot set property 'range' of undefined #1017

Closed MarkLyck closed 4 years ago

MarkLyck commented 4 years ago

Describe the bug When loading cubejs I'm getting this error:

webpack-internal:///./node_modules/next/dist/client/next-dev.js:62 Error was not caught TypeError: Cannot set property 'range' of undefined
    at Object.u [as extendMoment] (webpack-internal:///./node_modules/moment-range/dist/moment-range.js:1)
    at eval (webpack-internal:///./node_modules/@cubejs-client/core/dist/cubejs-client-core.js:63)
    at Object../node_modules/@cubejs-client/core/dist/cubejs-client-core.js (_app.js:2737)
    at __webpack_require__ (webpack.js:878)
    at fn (webpack.js:151)
    at Module.eval (webpack-internal:///./src/lib/cubejs/index.tsx:6)
    at eval (webpack-internal:///./src/lib/cubejs/index.tsx:123)
    at Module../src/lib/cubejs/index.tsx (_app.js:21449)
    at __webpack_require__ (webpack.js:878)
    at fn (webpack.js:151)
    at Module.eval (webpack-internal:///./src/lib/Providers.tsx:10)
    at eval (webpack-internal:///./src/lib/Providers.tsx:213)
    at Module../src/lib/Providers.tsx (_app.js:21437)
    at __webpack_require__ (webpack.js:878)
    at fn (webpack.js:151)
    at Module.eval (webpack-internal:///./src/pages/_app.tsx:15)
    at eval (webpack-internal:///./src/pages/_app.tsx:132)
    at Module../src/pages/_app.tsx (_app.js:21617)
    at __webpack_require__ (webpack.js:878)
    at fn (webpack.js:151)
    at eval (webpack-internal:///./node_modules/next/dist/build/webpack/loaders/next-client-pages-loader.js?page=%2F_app&absolutePagePath=private-next-pages%2F_app.tsx!./:5)
    at register (webpack-internal:///./node_modules/next/dist/client/page-loader.js:299)
    at PageLoader.registerPage (webpack-internal:///./node_modules/next/dist/client/page-loader.js:336)
    at Array.register [as push] (webpack-internal:///./node_modules/next/dist/client/index.js:110)
    at eval (webpack-internal:///./node_modules/next/dist/build/webpack/loaders/next-client-pages-loader.js?page=%2F_app&absolutePagePath=private-next-pages%2F_app.tsx!./:2)
    at Object../node_modules/next/dist/build/webpack/loaders/next-client-pages-loader.js?page=%2F_app&absolutePagePath=private-next-pages%2F_app.tsx!./ (_app.js:12370)
    at __webpack_require__ (webpack.js:878)
    at fn (webpack.js:151)
    at Object.2 (_app.js:21689)
    at __webpack_require__ (webpack.js:878)
    at checkDeferredModules (webpack.js:46)
    at Array.webpackJsonpCallback [as push] (webpack.js:33)
    at _app.js:2

To Reproduce Steps to reproduce the behavior:

  1. Set up CubeJS w/ websocket.
  2. Run app.

My cubeJS Provider (this wraps my entire application).

(even loading this file causes the error. Even if it just returns an empty div and never runs initCubejs it will fail. So it looks like just importing cubejs libraries causes the error.

import React, { useContext } from 'react'
import cubejs from '@cubejs-client/core'
import WebSocketTransport from '@cubejs-client/ws-transport'
import { CubeProvider } from '@cubejs-client/react'
import { authContext } from '~/common/contexts'
import { isBrowser } from '~/common/utils/featureTests'

const API_URL = 'https://cubejs.colonynetworks.com'

export let cubejsApi: any

export const initCubeJS = (authToken: string) => {
  if (!!cubejsApi) return cubejsApi
  if (!isBrowser) return

  // @ts-ignore
  cubejsApi = cubejs({
    transport: new WebSocketTransport({
      authorization: authToken,
      apiUrl: API_URL.replace('http', 'ws'),
    }),
  })

  return cubejsApi
}

const Provider = ({ children }) => {
  const auth = useContext(authContext)
  if (!auth) return null

  return <CubeProvider cubejsApi={initCubeJS(auth.authToken)}>{children}</CubeProvider>
}

export default Provider

Expected behavior Expected cube to load.

Screenshots If applicable, add screenshots to help explain your problem.

Screen Shot 2020-08-22 at 21 29 09

Version: 0.19.56

Additional context Might be related to https://github.com/rotaready/moment-range/issues/238

MarkLyck commented 4 years ago

Ahh figured it out.

Ended up being an incompatibility with antd-dayjs-webpack-plugin. Removed that plugin and it's working.