vercel / next.js

The React Framework
https://nextjs.org
MIT License
126.87k stars 26.97k forks source link

Next.js on Docker/Digital Ocean: Unknown system error -116, stat '/usr/src/app/pages/index.js' #4007

Closed ateufel closed 6 years ago

ateufel commented 6 years ago

Expected Behavior

I am using Docker on Digital Ocean for a Next.js based project, the main page is pretty simple and should just show nothing more than a Facebook login button.

Current Behavior

If i try to access it via Browser, the first time it works well and the Login button shows up - if i refresh the page, i get the following error on my screen: Error: Unknown system error -116: Unknown system error -116, stat '/usr/src/app/pages/overview.js'

Steps to Reproduce (for bugs)

The index page is very simple:

import React from 'react';
import PropTypes from 'prop-types';
import {Button} from 'antd';
import {bindActionCreators} from 'redux';
import {initStore} from '../store';
import withRedux from 'next-redux-wrapper';
import * as userActionCreators from '../actions/user';

class Index extends React.Component {
    constructor(props) {
        super(props);
        this.state = {

        };
    }
    componentDidMount() {
        const {checkLogin} = this.props.userActions;
        //checkLogin(true); //disabled for now, but it makes no difference
    }
    onLoginClick = () => {
        const {doLogin} = this.props.userActions;
        doLogin();
    };
    render() {
        const {isRequestingLoginStatus} = this.props.user;

        return (
            <div>
                <Button className="loginBtn" onClick={this.onLoginClick} type="primary"
                    loading={isRequestingLoginStatus}>Login</Button>
                <style jsx>{`
              .loginBtn {

              }
            `}</style>
            </div>
        );
    }
}

Index.propTypes = {
    userActions: PropTypes.object,
    user: PropTypes.object
};

const mapStateToProps = (state) => {
    return {
        user: state.user
    };
};

function mapDispatchToProps(dispatch) {
    return {
        userActions: bindActionCreators(userActionCreators, dispatch)
    };
}

export default withRedux(initStore, mapStateToProps, mapDispatchToProps)(Index);

I installed Sentry and it showed the following additional error information, the "touch" package is used by Next.js:

Error: Unknown system error -116: Unknown system error -116, open '/usr/src/app/pages/index.js'
  File "fs.js", line 667, in Object.fs.openSync
  File "/usr/src/app/node_modules/touch/index.js", line 176, in TouchSync.open
    this.onopen(null, fs.openSync(this.path, this.oflags))
  File "/usr/src/app/node_modules/touch/index.js", line 82, in new Touch
    this.open()
  File "/usr/src/app/node_modules/touch/index.js", line 173, in new TouchSync
    class TouchSync extends Touch {
  File "/usr/src/app/node_modules/touch/index.js", line 20, in Function.module.exports.sync.module.exports.touchSync
    (new TouchSync(validOpts(options, f, null)), undefined)
...
(4 additional frame(s) were not displayed)

Screenshot of the Error, including Dev Tools: next-error My Dockerfile for Next.js:

FROM node:latest
MAINTAINER Andreas Teufel <a.teufel@limesoda.com>
WORKDIR /usr/src/app
COPY package*.json ./
COPY yarn.lock ./
RUN yarn install
COPY . .
RUN yarn global add pm2
EXPOSE 3000
CMD ["pm2-runtime", "./docker/node/process.yml"]

Your Environment

Tech Version
next 5.0.0
node 8.x
OS Ubuntu 17.10 on Digital Ocean
browser latest Firefox/Chrome
docker 17.12.0-ce-win47
timneutkens commented 6 years ago

Please make sure you're starting the server in production mode and not development, because the touch module is only used in development, to be precise, here: https://github.com/zeit/next.js/blob/c204cdd91e62e91ecdb14cd6bc4588335ccf5a4e/server/on-demand-entry-handler.js#L5

ateufel commented 6 years ago

that fixed it, thank you so much!

timneutkens commented 6 years ago

🙏