Skip to content

frequent server crashes with "Cannot read propert 'children' of undefined" #4503

@jeffwillette

Description

@jeffwillette

Description

Describe the issue or the enhancement that you want to see.

Steps to reproduce

I don't have a large enough scope of the problem to get repro steps yet, will add them when and if I do.

Clear steps describing how to reproduce the issue.

Expected result

No dev server crash

What should happen?

Actual result

server crashed with trace

info file deleted at /Users/Jeff/go/src/github.com/deltaskelta/interviews/frontend/src/pages/app/index.js
error UNHANDLED EXCEPTION


  TypeError: Cannot read property 'children' of undefined

  - actions.js:379 actions.deleteNode
    [frontend]/[gatsby]/dist/redux/actions.js:379:54

  - bindActionCreators.js:7 Object.deleteNode
    [frontend]/[redux]/lib/bindActionCreators.js:7:35

  - gatsby-node.js:163
    [frontend]/[gatsby]/dist/internal-plugins/internal-data-bridge/gatsby-node.js:163:23

  - mitt.js:1
    [frontend]/[mitt]/dist/mitt.js:1:268

  - Array.map

  - mitt.js:1 Object.emit
    [frontend]/[mitt]/dist/mitt.js:1:252

  - index.js:72
    [frontend]/[gatsby]/dist/redux/index.js:72:11

  - createStore.js:186 dispatch
    [frontend]/[redux]/lib/createStore.js:186:7

  - index.js:58
    [frontend]/[gatsby]/dist/redux/index.js:58:79

  - bindActionCreators.js:7
    [frontend]/[redux]/lib/bindActionCreators.js:7:12

  - api-runner-node.js:47 doubleBoundActionCreators.(anonymous function)
    [frontend]/[gatsby]/dist/utils/api-runner-node.js:47:13

  - gatsby-node.js:69
    [frontend]/[gatsby]/dist/internal-plugins/component-page-creator/gatsby-node.js:69:17

  - Array.forEach

  - gatsby-node.js:68 FSWatcher.<anonymous>
    [frontend]/[gatsby]/dist/internal-plugins/component-page-creator/gatsby-node.js:68:18

  - index.js:196 FSWatcher.<anonymous>
    [frontend]/[chokidar]/index.js:196:15


error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh
Arguments: -c gatsby develop
Directory: /Users/Jeff/go/src/github.com/deltaskelta/interviews/frontend
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/Users/Jeff/go/src/github.com/deltaskelta/interviews/frontend/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

What happened.

Environment

I am in the middle of trying to integrate an external Apollo store when this happens, It happens when I am editing and saving graphql queries that are external to gatsby's static build queries

  • Gatsby version (npm list gatsby): [email protected]
  • gatsby-cli version (gatsby --version): 1.1.41
  • Node.js version: v9.8.0
  • Operating System: OSSierra 10.13.3

File contents (if changed):

gatsby-config.js:
package.json:
gatsby-node.js:
gatsby-browser.js:

import { ApolloLink } from 'apollo-link';
import { ApolloProvider } from 'react-apollo';
import { HttpLink, InMemoryCache } from 'apollo-client-preset';
import { Provider } from 'react-redux';
import { withClientState } from 'apollo-link-state';
import PropTypes from 'prop-types';

import { ApolloClient } from 'apollo-client';
import { Router } from 'react-router-dom';
import React from 'react';

import { getCookie } from './utils';
import apolloState from './src/state/defaults';
import newStore from './src/state/createStore';
import resolvers from './src/state/resolvers';
import urls from './urls';

// this is for the usage of redux
exports.replaceRouterComponent = ({ history }) => {
  const ConnectedRouterWrapper = ({ children }) => {
    const store = newStore();
    return (
      <Provider store={store}>
        <Router history={history}>{children}</Router>
      </Provider>
    );
  };

  ConnectedRouterWrapper.propTypes = {
    children: PropTypes.object
  };

  return ConnectedRouterWrapper;
};

exports.wrapRootComponent = ({ Root }) => {
  return () => {
    const cache = new InMemoryCache();

    const stateLink = withClientState({ resolvers, cache, apolloState });

    const httpLink = new HttpLink({
      uri: urls.graphqlServer + urls.graphqlEndpoint,
      credentials: 'same-origin',
      headers: {
        authorization: getCookie('Authorization')
      }
    });

    const client = new ApolloClient({
      cache,
      link: new ApolloLink.from([stateLink, httpLink]),
      connectToDevTools: true
    });

    window.__APOLLO_CLIENT__ = client;

    return (
      <ApolloProvider client={client}>
        <Root />
      </ApolloProvider>
    );
  };
};

gatsby-ssr.js:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions