问:
NextJS Blank Page in Production Build in Docker Only
I am running into an issue that just started yesterday, December 7th 2021 around midday EST. I have a NextJS application deployed in a Docker container. Deploying this app in production mode from inside a container now gives a blank page and a React minify error in the browser console (more details below).

Prior to yesterday I have had no such issue.

This issue is reproducable in a Docker container running both on an AWS EC2 instance and my local machine. There are no errors displayed during local development with npm run dev nor when running npm run build && npm run start OUTSIDE a docker container. Everything develops, builds and displays fine on my local development environment.

INSIDE the docker container I can run the project fine and load the page with npm run dev, but the error seems to be specific to a production build inside this Docker container. Here is the Dockerfile configuration:

```<code># Install dependencies only when needed
FROM node:14-buster-slim AS deps

WORKDIR /app
COPY package.json ./

RUN apt-get update && apt-get install -y g++ make cmake python

RUN npm install --frozen-lockfile

# clean up any extra apt packages to save on space
RUN apt-get remove -y g++ make cmake python
RUN apt autoremove -y

# Rebuild the source code only when needed
FROM node:14-buster-slim AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN apt-get update && apt-get install -y g++ make cmake python
RUN npm run build && npm install --production --ignore-scripts --prefer-offline

# clean up any extra apt packages to save on space
RUN apt-get remove -y g++ make cmake python
RUN apt autoremove -y

# Production image, copy all the files and run next
FROM node:14-buster-slim AS runner
WORKDIR /app

# install cron and curl for the expiringCertificates cron job
RUN apt-get update && apt-get -y install cron curl

# make a folder where the cron job can store cookies as text files (see expiringCertificatesCron.sh for reference)
RUN mkdir /app/cron

# Copy cron files to the cron.d directory
COPY --from=builder /app/cron/expiringCertificatesCron /etc/cron.d/expiringCertificatesCron
COPY --from=builder /app/cron/expiringCertificatesCron.sh /app/cron/expiringCertificatesCron.sh

# modify permissions of both cron files to ensure they can be used properly
RUN chmod 0644 /etc/cron.d/expiringCertificatesCron
RUN chmod +x /app/cron/expiringCertificatesCron.sh

# apply the cron job
RUN crontab /etc/cron.d/expiringCertificatesCron

# Create the log file for cron to be able to run tail
RUN touch /var/log/cron.log

ENV NODE_ENV production

COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/.env.production.local ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json

EXPOSE 3000

ENV PORT 3000

CMD ["sh", "-c", "cron && node_modules/.bin/next start"]
</code>```

I found this issue when re-building and deploying to production around noon EST, and was surprised to see a blank site, with no title, some of my dark grey css styling, and the following errors in the browser console.

```<code>main-deb592798b94b511.js:1 Error: Minified React error #200; visit https://reactjs.org/docs/error-decoder.html?invariant=200 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at Object.t.hydrate (framework-8957c350a55da097.js:1)
    at d.default.createElement.callbacks (main-deb592798b94b511.js:1)
    at xe (main-deb592798b94b511.js:1)
    at main-deb592798b94b511.js:1
    at s (main-deb592798b94b511.js:1)
    at Generator._invoke (main-deb592798b94b511.js:1)
    at Generator.S.forEach.e.<computed> [as next] (main-deb592798b94b511.js:1)
    at L (main-deb592798b94b511.js:1)
    at i (main-deb592798b94b511.js:1)
    at main-deb592798b94b511.js:1
ye @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
s @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
S.forEach.e.<computed> @ main-deb592798b94b511.js:1
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
de @ main-deb592798b94b511.js:1
ve @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
s @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
S.forEach.e.<computed> @ main-deb592798b94b511.js:1
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
he @ main-deb592798b94b511.js:1
t.initNext @ main-deb592798b94b511.js:1
2870 @ main-deb592798b94b511.js:1
n @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1
n.O @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1
t @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1

main-deb592798b94b511.js:1 A client-side exception has occurred, see here for more info: https://nextjs.org/docs/messages/client-side-exception-occurred
ye @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
s @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
S.forEach.e.<computed> @ main-deb592798b94b511.js:1
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
de @ main-deb592798b94b511.js:1
ve @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
s @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
S.forEach.e.<computed> @ main-deb592798b94b511.js:1
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
he @ main-deb592798b94b511.js:1
t.initNext @ main-deb592798b94b511.js:1
2870 @ main-deb592798b94b511.js:1
n @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1
n.O @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1
t @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1

main-deb592798b94b511.js:1 Uncaught (in promise) Error: Cancel rendering route
    at oe (main-deb592798b94b511.js:1)
    at main-deb592798b94b511.js:1
    at new Promise (<anonymous>)
    at xe (main-deb592798b94b511.js:1)
    at main-deb592798b94b511.js:1
oe @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
xe @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
Promise.then (async)
(anonymous) @ main-deb592798b94b511.js:1
Promise.then (async)
ye @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
s @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
S.forEach.e.<computed> @ main-deb592798b94b511.js:1
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
de @ main-deb592798b94b511.js:1
ve @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
s @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
S.forEach.e.<computed> @ main-deb592798b94b511.js:1
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
he @ main-deb592798b94b511.js:1
t.initNext @ main-deb592798b94b511.js:1
2870 @ main-deb592798b94b511.js:1
n @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1
n.O @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1
t @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1

framework-8957c350a55da097.js:1 Uncaught (in promise) Error: Minified React error #200; visit https://reactjs.org/docs/error-decoder.html?invariant=200 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at Object.t.hydrate (framework-8957c350a55da097.js:1)
    at d.default.createElement.callbacks (main-deb592798b94b511.js:1)
    at xe (main-deb592798b94b511.js:1)
    at main-deb592798b94b511.js:1
</code>```

I can see all minified JS files downloaded successfully in the Network tab, and there are no errors in the server console. Here is the DOM for the blank site (I can see it tried to load my FullPageLoader component but nothing is actually displayed):

Blank DOM

Here is my package.json:

```<code>{
  "name": "website",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "cross-env NODE_OPTIONS='--inspect' next dev",
    "build": "next build --debug",
    "start": "next start",
    "lint": "next lint",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:coverage": "jest --coverage"
  },
  "dependencies": {
    "aws-sdk": "^2.1021.0",
    "bcrypt": "^5.0.1",
    "cookie": "^0.4.1",
    "jsonwebtoken": "^8.5.1",
    "next": "^12.0.2",
    "node-ssh": "^12.0.0",
    "nodemailer": "^6.7.0",
    "react": "17.0.2",
    "react-dom": "^17.0.2",
    "react-hook-form": "^7.16.1",
    "react-icons": "^4.2.0",
    "react-router-dom": "^5.3.0",
    "sass": "^1.38.0",
    "serverless-mysql": "^1.5.4",
    "swr": "^0.5.6",
    "uuid": "^8.3.2"
  },
  "devDependencies": {
    "@babel/core": "^7.15.0",
    "@babel/preset-typescript": "^7.15.0",
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^12.0.0",
    "@types/bcrypt": "^5.0.0",
    "@types/cookie": "^0.4.1",
    "@types/jest": "^27.0.1",
    "@types/jsonwebtoken": "^8.5.5",
    "@types/node": "^16.6.1",
    "@types/nodemailer": "^6.4.4",
    "@types/react": "17.0.18",
    "@types/react-dom": "^17.0.9",
    "@types/react-router-dom": "^5.3.1",
    "@types/ssh2": "^0.5.48",
    "@types/uuid": "^8.3.3",
    "@typescript-eslint/eslint-plugin": "^4.29.1",
    "@typescript-eslint/parser": "^4.29.1",
    "babel-jest": "^27.0.6",
    "cross-env": "^7.0.3",
    "eslint": "^7.32.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-config-next": "11.1.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-import": "^2.24.0",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-prettier": "^3.4.0",
    "eslint-plugin-react": "^7.24.0",
    "eslint-plugin-react-hooks": "^4.2.0",
    "jest": "^27.0.6",
    "jest-environment-jsdom": "^27.0.6",
    "prettier": "^2.3.2",
    "ts-jest": "^27.0.4",
    "typescript": "4.3.5"
  },
  "description": "This is a [React.js](https://reactjs.org/) project using the [Next.js](https://nextjs.org/) framework to help with routing, rendering, and more. For styling the project includes [Sass](https://sass-lang.com/) to add superpowers to our CSS.",
  "main": ".eslintrc.js",
  "repository": {
    "type": "git",
    "url": "<hidden>"
  },
  "keywords": [
    ""
  ],
  "author": "<hidden>",
  "license": "ISC"
}
</code>```

NOTE: Rolling back to previous working commits yields the same issue.

The only hint I have to go off of is that in the failing deployment I started seeing the following postcss deprecation warning while building the project, before yesterday I did not see this warning:

```<code>> next build

info  - Loaded env from /app/.env.production.local
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry

info  - Skipping validation of types...
info  - Creating an optimized production build...
postcss-resolve-url: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
postcss-resolve-url: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
</code>```

Without any way to properly debug in a production build, I'm not sure what could be causing the minify errors. Any help would be greatly appreciated!

答: Unfortunately/fortunately the issue resolved itself after updating NPM packages on about December 15th. Can only assume one package was causing issues and updating all of them to the latest version fixed the issue.</p>

Body:
I am running into an issue that just started yesterday, December 7th 2021 around midday EST. I have a NextJS application deployed in a Docker container. Deploying this app in production mode from inside a container now gives a blank page and a React minify error in the browser console (more details below).

Prior to yesterday I have had no such issue.

This issue is reproducable in a Docker container running both on an AWS EC2 instance and my local machine. There are no errors displayed during local development with npm run dev nor when running npm run build && npm run start OUTSIDE a docker container. Everything develops, builds and displays fine on my local development environment.

INSIDE the docker container I can run the project fine and load the page with npm run dev, but the error seems to be specific to a production build inside this Docker container. Here is the Dockerfile configuration:

# Install dependencies only when needed
FROM node:14-buster-slim AS deps

WORKDIR /app
COPY package.json ./

RUN apt-get update && apt-get install -y g++ make cmake python

RUN npm install --frozen-lockfile

# clean up any extra apt packages to save on space
RUN apt-get remove -y g++ make cmake python
RUN apt autoremove -y

# Rebuild the source code only when needed
FROM node:14-buster-slim AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN apt-get update && apt-get install -y g++ make cmake python
RUN npm run build && npm install --production --ignore-scripts --prefer-offline

# clean up any extra apt packages to save on space
RUN apt-get remove -y g++ make cmake python
RUN apt autoremove -y

# Production image, copy all the files and run next
FROM node:14-buster-slim AS runner
WORKDIR /app

# install cron and curl for the expiringCertificates cron job
RUN apt-get update && apt-get -y install cron curl

# make a folder where the cron job can store cookies as text files (see expiringCertificatesCron.sh for reference)
RUN mkdir /app/cron

# Copy cron files to the cron.d directory
COPY --from=builder /app/cron/expiringCertificatesCron /etc/cron.d/expiringCertificatesCron
COPY --from=builder /app/cron/expiringCertificatesCron.sh /app/cron/expiringCertificatesCron.sh

# modify permissions of both cron files to ensure they can be used properly
RUN chmod 0644 /etc/cron.d/expiringCertificatesCron
RUN chmod +x /app/cron/expiringCertificatesCron.sh

# apply the cron job
RUN crontab /etc/cron.d/expiringCertificatesCron

# Create the log file for cron to be able to run tail
RUN touch /var/log/cron.log

ENV NODE_ENV production

COPY --from=builder /app/next.config.js ./
COPY --from=builder /app/.env.production.local ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json

EXPOSE 3000

ENV PORT 3000

CMD ["sh", "-c", "cron && node_modules/.bin/next start"]

I found this issue when re-building and deploying to production around noon EST, and was surprised to see a blank site, with no title, some of my dark grey css styling, and the following errors in the browser console.

main-deb592798b94b511.js:1 Error: Minified React error #200; visit https://reactjs.org/docs/error-decoder.html?invariant=200 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at Object.t.hydrate (framework-8957c350a55da097.js:1)
    at d.default.createElement.callbacks (main-deb592798b94b511.js:1)
    at xe (main-deb592798b94b511.js:1)
    at main-deb592798b94b511.js:1
    at s (main-deb592798b94b511.js:1)
    at Generator._invoke (main-deb592798b94b511.js:1)
    at Generator.S.forEach.e.<computed> [as next] (main-deb592798b94b511.js:1)
    at L (main-deb592798b94b511.js:1)
    at i (main-deb592798b94b511.js:1)
    at main-deb592798b94b511.js:1
ye @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
s @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
S.forEach.e.<computed> @ main-deb592798b94b511.js:1
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
de @ main-deb592798b94b511.js:1
ve @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
s @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
S.forEach.e.<computed> @ main-deb592798b94b511.js:1
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
he @ main-deb592798b94b511.js:1
t.initNext @ main-deb592798b94b511.js:1
2870 @ main-deb592798b94b511.js:1
n @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1
n.O @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1
t @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1

main-deb592798b94b511.js:1 A client-side exception has occurred, see here for more info: https://nextjs.org/docs/messages/client-side-exception-occurred
ye @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
s @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
S.forEach.e.<computed> @ main-deb592798b94b511.js:1
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
de @ main-deb592798b94b511.js:1
ve @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
s @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
S.forEach.e.<computed> @ main-deb592798b94b511.js:1
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
he @ main-deb592798b94b511.js:1
t.initNext @ main-deb592798b94b511.js:1
2870 @ main-deb592798b94b511.js:1
n @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1
n.O @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1
t @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1

main-deb592798b94b511.js:1 Uncaught (in promise) Error: Cancel rendering route
    at oe (main-deb592798b94b511.js:1)
    at main-deb592798b94b511.js:1
    at new Promise (<anonymous>)
    at xe (main-deb592798b94b511.js:1)
    at main-deb592798b94b511.js:1
oe @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
xe @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
Promise.then (async)
(anonymous) @ main-deb592798b94b511.js:1
Promise.then (async)
ye @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
s @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
S.forEach.e.<computed> @ main-deb592798b94b511.js:1
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
de @ main-deb592798b94b511.js:1
ve @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
s @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
S.forEach.e.<computed> @ main-deb592798b94b511.js:1
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
Promise.then (async)
L @ main-deb592798b94b511.js:1
i @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
(anonymous) @ main-deb592798b94b511.js:1
he @ main-deb592798b94b511.js:1
t.initNext @ main-deb592798b94b511.js:1
2870 @ main-deb592798b94b511.js:1
n @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1
n.O @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1
t @ webpack-cf0a2826ddaf11f3.js:1
(anonymous) @ main-deb592798b94b511.js:1

framework-8957c350a55da097.js:1 Uncaught (in promise) Error: Minified React error #200; visit https://reactjs.org/docs/error-decoder.html?invariant=200 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at Object.t.hydrate (framework-8957c350a55da097.js:1)
    at d.default.createElement.callbacks (main-deb592798b94b511.js:1)
    at xe (main-deb592798b94b511.js:1)
    at main-deb592798b94b511.js:1

I can see all minified JS files downloaded successfully in the Network tab, and there are no errors in the server console. Here is the DOM for the blank site (I can see it tried to load my FullPageLoader component but nothing is actually displayed):

Blank DOM

Here is my package.json:

{
  "name": "website",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "cross-env NODE_OPTIONS='--inspect' next dev",
    "build": "next build --debug",
    "start": "next start",
    "lint": "next lint",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:coverage": "jest --coverage"
  },
  "dependencies": {
    "aws-sdk": "^2.1021.0",
    "bcrypt": "^5.0.1",
    "cookie": "^0.4.1",
    "jsonwebtoken": "^8.5.1",
    "next": "^12.0.2",
    "node-ssh": "^12.0.0",
    "nodemailer": "^6.7.0",
    "react": "17.0.2",
    "react-dom": "^17.0.2",
    "react-hook-form": "^7.16.1",
    "react-icons": "^4.2.0",
    "react-router-dom": "^5.3.0",
    "sass": "^1.38.0",
    "serverless-mysql": "^1.5.4",
    "swr": "^0.5.6",
    "uuid": "^8.3.2"
  },
  "devDependencies": {
    "@babel/core": "^7.15.0",
    "@babel/preset-typescript": "^7.15.0",
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^12.0.0",
    "@types/bcrypt": "^5.0.0",
    "@types/cookie": "^0.4.1",
    "@types/jest": "^27.0.1",
    "@types/jsonwebtoken": "^8.5.5",
    "@types/node": "^16.6.1",
    "@types/nodemailer": "^6.4.4",
    "@types/react": "17.0.18",
    "@types/react-dom": "^17.0.9",
    "@types/react-router-dom": "^5.3.1",
    "@types/ssh2": "^0.5.48",
    "@types/uuid": "^8.3.3",
    "@typescript-eslint/eslint-plugin": "^4.29.1",
    "@typescript-eslint/parser": "^4.29.1",
    "babel-jest": "^27.0.6",
    "cross-env": "^7.0.3",
    "eslint": "^7.32.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-config-next": "11.1.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-import": "^2.24.0",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-prettier": "^3.4.0",
    "eslint-plugin-react": "^7.24.0",
    "eslint-plugin-react-hooks": "^4.2.0",
    "jest": "^27.0.6",
    "jest-environment-jsdom": "^27.0.6",
    "prettier": "^2.3.2",
    "ts-jest": "^27.0.4",
    "typescript": "4.3.5"
  },
  "description": "This is a [React.js](https://reactjs.org/) project using the [Next.js](https://nextjs.org/) framework to help with routing, rendering, and more. For styling the project includes [Sass](https://sass-lang.com/) to add superpowers to our CSS.",
  "main": ".eslintrc.js",
  "repository": {
    "type": "git",
    "url": "<hidden>"
  },
  "keywords": [
    ""
  ],
  "author": "<hidden>",
  "license": "ISC"
}

NOTE: Rolling back to previous working commits yields the same issue.

The only hint I have to go off of is that in the failing deployment I started seeing the following postcss deprecation warning while building the project, before yesterday I did not see this warning:

> next build

info  - Loaded env from /app/.env.production.local
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry

info  - Skipping validation of types...
info  - Creating an optimized production build...
postcss-resolve-url: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration
postcss-resolve-url: postcss.plugin was deprecated. Migration guide:
https://evilmartians.com/chronicles/postcss-8-plugin-migration

Without any way to properly debug in a production build, I'm not sure what could be causing the minify errors. Any help would be greatly appreciated!


来源: stackexchange

问:
ORA-65169: error encountered while attempting to copy file
Hi im trying to create clone_link between two ora19 databases due to cloning PDB databases

both DBs have created user like:

```<code>CREATE USER c##remote_clone_user IDENTIFIED BY remote_clone_user CONTAINER=ALL;
GRANT CREATE SESSION, CREATE PLUGGABLE DATABASE TO c##remote_clone_user CONTAINER=ALL;
</code>```

i want to copy PDB from DB2 to DB1 so i closed wanted PDB on DB2 and opened for reading:

```<code>alter pluggable database testpdb close;
alter pluggable database testpdb open read only;
</code>```

from DB1 have created clone_link and tried to copy PDB (tns testpdb connection is set to DB2)

```<code>--db link to database we want to copy
create database link clone_link
    connect to C##remote_clone_user identified by remote_clone_user using 'testpdb';

-- clone from DB2 to DB1
create pluggable database testpdb from testpdb@clone_link
    file_name_convert = ('/u01/app/oracle/oradata/', '/testpdb/');
</code>```

but im getting error :

```<code>Error starting at line : 14 in command -
create pluggable database testpdb from testpdb@clone_link
    file_name_convert = ('/u01/app/oracle/oradata/', '/testpdb/')
Error report -
ORA-65169: error encountered while attempting to copy file /u01/app/oracle/oradata/testpdb/testpdb_index.dbf
ORA-19504: failed to create file "/testpdb/testpdb/testpdb_index.dbf"
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 13: Permission denied
Additional information: 3
65169. 00000 -  "error encountered while attempting to copy file %s "
*Cause:    An error was encountered while attempting to copy the file
           while creating a pluggable database.
*Action:   Check additional error messages for the cause of the failure to
           copy the file, and resolve the issue accordingly.
</code>```

in alert log i see only :

```<code>Undo Create of Pluggable Database TESTPDB with pdb id - 7.
**************************************************************
ORA-65169 signalled during: create pluggable database testpdb from testpdb@clone_link
    file_name_convert = ('/u01/app/oracle/oradata/', '/testpdb/')...
</code>```

i am not sure what permissions need to be set

答:
Its working for me
in CDB</p>
```<code>alter system set "_exadata_feature_on" =true scope=spfile;
shutdown immediate;
startup;
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Hi im trying to create clone_link between two ora19 databases due to cloning PDB databases

both DBs have created user like:

CREATE USER c##remote_clone_user IDENTIFIED BY remote_clone_user CONTAINER=ALL;
GRANT CREATE SESSION, CREATE PLUGGABLE DATABASE TO c##remote_clone_user CONTAINER=ALL;

i want to copy PDB from DB2 to DB1 so i closed wanted PDB on DB2 and opened for reading:

alter pluggable database testpdb close;
alter pluggable database testpdb open read only;

from DB1 have created clone_link and tried to copy PDB (tns testpdb connection is set to DB2)

--db link to database we want to copy
create database link clone_link
    connect to C##remote_clone_user identified by remote_clone_user using 'testpdb';

-- clone from DB2 to DB1
create pluggable database testpdb from testpdb@clone_link
    file_name_convert = ('/u01/app/oracle/oradata/', '/testpdb/');

but im getting error :

Error starting at line : 14 in command -
create pluggable database testpdb from testpdb@clone_link
    file_name_convert = ('/u01/app/oracle/oradata/', '/testpdb/')
Error report -
ORA-65169: error encountered while attempting to copy file /u01/app/oracle/oradata/testpdb/testpdb_index.dbf
ORA-19504: failed to create file "/testpdb/testpdb/testpdb_index.dbf"
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 13: Permission denied
Additional information: 3
65169. 00000 -  "error encountered while attempting to copy file %s "
*Cause:    An error was encountered while attempting to copy the file
           while creating a pluggable database.
*Action:   Check additional error messages for the cause of the failure to
           copy the file, and resolve the issue accordingly.

in alert log i see only :

Undo Create of Pluggable Database TESTPDB with pdb id - 7.
**************************************************************
ORA-65169 signalled during: create pluggable database testpdb from testpdb@clone_link
    file_name_convert = ('/u01/app/oracle/oradata/', '/testpdb/')...

i am not sure what permissions need to be set

Body:
Its working for me
in CDB

alter system set "_exadata_feature_on" =true scope=spfile;
shutdown immediate;
startup;


问:
Would somebody be willing to explain CHESS to a programmer new to Unit Testing?
I've just recently started using unit testing, and I understand some of the main issues unit testing does not cover is concurrency and complex cross-object interactions (which most modern fully OOP lanugages completely eliminate anyhow.)  it is my understanding that CHESS resolves the concurrency problem to some degree? could someone give me the skinny of what chess is, how it works, and what the drawbacks are?</p>

答:
The basic idea is that race conditions (when the output depends on which of two or more processes "gets there first" for some definition of "there") have only a finite number of possible orderings.

Thus if you can control the orderings, you can test them systematically.

If your code works as expected for all possible orderings, it's passes.  If not, it fails.

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: MarkusQ


问:
How to do this in one line using PHP
I have the following structure:

```<code>$par4 = json_decode($source_code)->$par1->$par2->$par3;
$par5 = $par4[0]->attributes->attribute[1]->value;
</code>```

where par1, par2 and par3 are strings. How do I chain the par4 and par5 on one line.

This does not work because of the array / object nesting I guess:

```<code>json_decode($source_code)->$par1->$par2->$par3[0]->attributes->attribute[1]->value;
</code>```

Here's the error:

```<code>Undefined property: stdClass::$o
</code>```

答:
I'm not sure, what you really need but try  using {} to highlight what you need</p>

```<code>{json_decode($source_code)->$par1->$par2->$par3}[0] // I think this is right
json_decode($source_code)->$par1->$par2->${par3[0]}
json_decode($source_code)->$par1->$par2->{$par3[0]}
</code>```

ContentLicense: CC BY-SA 3.0

Title: How to do this in one line using PHP

Body:
I have the following structure:

$par4 = json_decode($source_code)->$par1->$par2->$par3;
$par5 = $par4[0]->attributes->attribute[1]->value;

where par1, par2 and par3 are strings. How do I chain the par4 and par5 on one line.

This does not work because of the array / object nesting I guess:

json_decode($source_code)->$par1->$par2->$par3[0]->attributes->attribute[1]->value;

Here's the error:

Undefined property: stdClass::$o

Body:
I'm not sure, what you really need but try  using {} to highlight what you need

{json_decode($source_code)->$par1->$par2->$par3}[0] // I think this is right
json_decode($source_code)->$par1->$par2->${par3[0]}
json_decode($source_code)->$par1->$par2->{$par3[0]}


问:
How to use current company in BQL query
I need to know how I can get the user's current company so that I can use it in the Where clause of a BQL query.  I'm not talking about the tenant "company".  I'm talking about the companies that are defined on screen CS101500.  I'm not seeing anything on the AccessInfo that seems to indicate the current Company.  The current Branch ID is there but, I need the company to which the branch belongs.

Using version 21.203

TIA!

答:
This will require the creation of a custom BQL element class.

IBqlOperand - A BQL Scalar operand

IBqlCreator - A Bql elements creator that requires implementation of AppendExpression and Verify methods.

```<code>public class CurrentOrganization : IBqlCreator, IBqlOperand
{

    #region Methods

    #region AppendExpression

    /// <summary>
    /// Appends the SQL tree expression that corresponds to the BQL command to an SQL tree query.
    /// </summary>
    /// <param name="exp">The SQL tree expression to be appended.</param>
    /// <param name="graph">A graph instance.</param>
    /// <param name="info">The information about the BQL command.</param>
    /// <param name="selection">The fragment of the BQL command that is translated to an SQL tree expression.</param>
    /// <returns></returns>
    public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
    {
        if (graph == null || !info.BuildExpression)
        {
            return true;
        }

        PXMutableCollection.AddMutableItem(this);

        exp = new SQLConst(graph.BranchOrganizationID());

        return true;
    }

    #endregion

    #region Verify

    /// <summary>
    /// No Clue.
    /// </summary>
    /// <param name="cache"></param>
    /// <param name="item"></param>
    /// <param name="pars"></param>
    /// <param name="result"></param>
    /// <param name="value"></param>
    public void Verify(PXCache cache, object item, List<object> pars, ref bool? result, ref object value)
    {
        value = cache.Graph.BranchOrganizationID();
    }

    #endregion

    #endregion

}
</code>```

The method call .BranchOrganizationID() is a PXGraph extension method that returns the OrganizationID from a Branch IPrefetchable

Calls to this prefetchable can be replaced with a BQL PXSelect :

PXSelect<Branch, Where<Branch.branchID,
Equal<Current<AccessInfo.branchID>>>>.Select(...)

Example usage would be as follows :

```<code>    [PXDefault(typeof(Search<Branch.branchID,Where<Branch.organizationID,Equal<CurrentOrganization>>>))]
</code>```

Title: How to use current company in BQL query

Body:
This will require the creation of a custom BQL element class.

IBqlOperand - A BQL Scalar operand

IBqlCreator - A Bql elements creator that requires implementation of AppendExpression and Verify methods.

public class CurrentOrganization : IBqlCreator, IBqlOperand
{

    #region Methods

    #region AppendExpression

    /// <summary>
    /// Appends the SQL tree expression that corresponds to the BQL command to an SQL tree query.
    /// </summary>
    /// <param name="exp">The SQL tree expression to be appended.</param>
    /// <param name="graph">A graph instance.</param>
    /// <param name="info">The information about the BQL command.</param>
    /// <param name="selection">The fragment of the BQL command that is translated to an SQL tree expression.</param>
    /// <returns></returns>
    public bool AppendExpression(ref SQLExpression exp, PXGraph graph, BqlCommandInfo info, BqlCommand.Selection selection)
    {
        if (graph == null || !info.BuildExpression)
        {
            return true;
        }

        PXMutableCollection.AddMutableItem(this);

        exp = new SQLConst(graph.BranchOrganizationID());

        return true;
    }

    #endregion

    #region Verify

    /// <summary>
    /// No Clue.
    /// </summary>
    /// <param name="cache"></param>
    /// <param name="item"></param>
    /// <param name="pars"></param>
    /// <param name="result"></param>
    /// <param name="value"></param>
    public void Verify(PXCache cache, object item, List<object> pars, ref bool? result, ref object value)
    {
        value = cache.Graph.BranchOrganizationID();
    }

    #endregion

    #endregion

}

The method call .BranchOrganizationID() is a PXGraph extension method that returns the OrganizationID from a Branch IPrefetchable

Calls to this prefetchable can be replaced with a BQL PXSelect :

PXSelect<Branch, Where<Branch.branchID,
Equal<Current<AccessInfo.branchID>>>>.Select(...)

Example usage would be as follows :

    [PXDefault(typeof(Search<Branch.branchID,Where<Branch.organizationID,Equal<CurrentOrganization>>>))]


问:
How to run a R script twice a day?
I had a R script configured to run via cron every day at 10am

```<code>library(cronR)
cmd2 = cron_rscript("CargueDiario_RedcapCovid_ODS.R", rscript_log="/home/admonda/R/projects/contagios_covid_santander/log/cargue_diario.log", log_append = T, log_timestamp = T)

cron_add(command = cmd2, frequency = 'daily', at = "10:00" , days_of_week = "*", id = 'FCVREDCAPCOVID_ODS_DIARIO', description = "FCVREDCAPCOVID_ODS_DIARIO")

cron_ls("FCVREDCAPCOVID_ODS_DIARIO")
## cronR job
## id:   FCVREDCAPCOVID_ODS_DIARIO
## tags:
## desc: FCVREDCAPCOVID_ODS_DIARIO
0 10 * * 0,1,2,3,4,5,6 /usr/lib/R/bin/Rscript '/home/admonda/R/projects/contagios_covid_santander/CargueDiario_RedcapCovid_ODS.R'  >> '/home/admonda/R/projects/contagios_covid_santander/log/cargue_diario.log' 2>&1
</code>```

Now i need to change it so it runs twice a day (10:00 and 22:00). I have already deleted it from CRON and I would like to make sure this is the correct new command:

```<code>cron_add(command = cmd2, frequency = 'daily', at = c("10:00","22:00") , days_of_week = "*", id = 'FCVREDCAPCOVID_ODS_DIARIO', description = "FCVREDCAPCOVID_ODS_DIARIO")
</code>```

答:
```<code>cron_add(command = cmd2, frequency = 'daily', at = 'c(10,22)', days_of_week = '*', id = '...', description = '...')
</code>```

Or just use cron expression:

```<code>cron_add(cmd, frequency = '0 10,22 * * *', id = '...', description = '...')
</code>```

source: https://www.rdocumentation.org/packages/cronR/versions/0.4.2/topics/cron_add

Title: How to run a R script twice a day?

Body:
I had a R script configured to run via cron every day at 10am

library(cronR)
cmd2 = cron_rscript("CargueDiario_RedcapCovid_ODS.R", rscript_log="/home/admonda/R/projects/contagios_covid_santander/log/cargue_diario.log", log_append = T, log_timestamp = T)

cron_add(command = cmd2, frequency = 'daily', at = "10:00" , days_of_week = "*", id = 'FCVREDCAPCOVID_ODS_DIARIO', description = "FCVREDCAPCOVID_ODS_DIARIO")

cron_ls("FCVREDCAPCOVID_ODS_DIARIO")
## cronR job
## id:   FCVREDCAPCOVID_ODS_DIARIO
## tags:
## desc: FCVREDCAPCOVID_ODS_DIARIO
0 10 * * 0,1,2,3,4,5,6 /usr/lib/R/bin/Rscript '/home/admonda/R/projects/contagios_covid_santander/CargueDiario_RedcapCovid_ODS.R'  >> '/home/admonda/R/projects/contagios_covid_santander/log/cargue_diario.log' 2>&1

Now i need to change it so it runs twice a day (10:00 and 22:00). I have already deleted it from CRON and I would like to make sure this is the correct new command:

cron_add(command = cmd2, frequency = 'daily', at = c("10:00","22:00") , days_of_week = "*", id = 'FCVREDCAPCOVID_ODS_DIARIO', description = "FCVREDCAPCOVID_ODS_DIARIO")

Body:
cron_add(command = cmd2, frequency = 'daily', at = 'c(10,22)', days_of_week = '*', id = '...', description = '...')

Or just use cron expression:

cron_add(cmd, frequency = '0 10,22 * * *', id = '...', description = '...')

source: https://www.rdocumentation.org/packages/cronR/versions/0.4.2/topics/cron_add


问:
Problem with filling the linked list with strtok
Im having troubles with the next piece of code...

I have defined a linked list struct

```<code>    typedef struct node {
        char *cmd;
        char *value;
        int delay;
        struct node *next;
    } node_t;
</code>```

im reading commands from a text file called commands.txt

```<code>write:0x02:1
read:0x04:2
set:0xff:2
reset:0xfa:2
</code>```

the code below works if i use two buffers (temp and temp1) but if i replace temp1 with temp it does not parse it correctly. it gives me

```<code>Tokenized2 read x04 1
Tokenized2 read 0x04 2
Tokenized2 read x04 1
Tokenized2 read 0x04 2
</code>```

The code is:

```<code>    char *filename = "commands.txt";
    FILE *fp = fopen(filename, "r");

    node_t *head = (node_t *)malloc(sizeof(node_t));
    node_t *hp = head;
    char temp[14];
    char temp1[14];

    fgets(temp, 14, fp);
    hp->cmd = strtok(temp, ":");
    hp->value = strtok(0, ":");
    hp->delay = atoi(strtok(0, ":"));
    hp->next = (node_t *)malloc(sizeof(node_t));
    hp = (node_t *)hp->next; Blaz

    fgets(temp1, 14, fp);
    hp->cmd = strtok(temp1, ":");
    hp->value = strtok(0, ":");
    hp->delay = atoi(strtok(0, ":"));
    hp->next = NULL;
    hp = head;

    printf("Tokenized2 %s %s %d\n", hp->cmd, hp->value, hp->delay);
    hp = hp->next;
    printf("Tokenized2 %s %s %d\n", head->next->cmd, head->next->value, head->next->delay);
    printf("Tokenized2 %s %s %d\n", head->cmd, head->value, head->delay);
    printf("Tokenized2 %s %s %d\n", head->next->cmd, head->next->value, head->next->delay);

    fclose(fp);
</code>```

The bottom printfs are redundant, I was just testing if it works with classic access to head and via pointer.
Eventually I would like to make this piece of code work.

```<code>    const unsigned MAX_LENGTH = 256;
    char cmdbuffer[MAX_LENGTH];
    node_t *head = (node_t *)malloc(sizeof(node_t));
    node_t *hp = head;
    while (fgets(cmdbuffer, MAX_LENGTH, fp)) {
        hp->cmd = strtok(cmdbuffer, ":");
        hp->value = strtok(0, ":");
        hp->delay = atoi(strtok(0, ":"));
        hp->next = (node_t *)malloc(sizeof(node_t));
        hp = (node_t *)hp->next;
    }
    hp->next = NULL;
    printf("Tokenized %s %s %d\n", head->cmd, head->value, head->delay);
    printf("Tokenized2 %s %s %d\n", head->next->cmd, head->next->value, head->next->delay);
</code>```

How can I solve this problem?

答:
I managed to solve it with strdup. Here is the code ...

```<code>FILE *fp = fopen("commands.txt", "r");

    if (fp == NULL){
        printf("Error: could not open text file");
        return 1;
    }

    const unsigned MAX_LENGTH = 256;
    char cmdbuffer[MAX_LENGTH];
    node_t* head = malloc(sizeof(node_t));
    node_t* hp = head;
    char* sdup;

    while (fgets(cmdbuffer, MAX_LENGTH, fp)){
        sdup = strdup(cmdbuffer);
        hp->cmd = strtok(sdup, ":");
        hp->value = strtok(0, ":");
        hp->delay = atoi(strtok(0, ":"));
        hp->next = malloc(sizeof(node_t));
        hp = (node_t*) hp->next;
    }
    hp->next = NULL;

    hp = head;
    while(hp){
        printf("Tokenized: %s %s %d\n", hp->cmd, hp->value, hp->delay);
        free(hp);
        hp = hp->next;
    }

</code>```

Comments/corrections are welcome!

Body:
Im having troubles with the next piece of code...

I have defined a linked list struct

    typedef struct node {
        char *cmd;
        char *value;
        int delay;
        struct node *next;
    } node_t;

im reading commands from a text file called commands.txt

write:0x02:1
read:0x04:2
set:0xff:2
reset:0xfa:2

the code below works if i use two buffers (temp and temp1) but if i replace temp1 with temp it does not parse it correctly. it gives me

Tokenized2 read x04 1
Tokenized2 read 0x04 2
Tokenized2 read x04 1
Tokenized2 read 0x04 2

The code is:

    char *filename = "commands.txt";
    FILE *fp = fopen(filename, "r");

    node_t *head = (node_t *)malloc(sizeof(node_t));
    node_t *hp = head;
    char temp[14];
    char temp1[14];

    fgets(temp, 14, fp);
    hp->cmd = strtok(temp, ":");
    hp->value = strtok(0, ":");
    hp->delay = atoi(strtok(0, ":"));
    hp->next = (node_t *)malloc(sizeof(node_t));
    hp = (node_t *)hp->next; Blaz

    fgets(temp1, 14, fp);
    hp->cmd = strtok(temp1, ":");
    hp->value = strtok(0, ":");
    hp->delay = atoi(strtok(0, ":"));
    hp->next = NULL;
    hp = head;

    printf("Tokenized2 %s %s %d\n", hp->cmd, hp->value, hp->delay);
    hp = hp->next;
    printf("Tokenized2 %s %s %d\n", head->next->cmd, head->next->value, head->next->delay);
    printf("Tokenized2 %s %s %d\n", head->cmd, head->value, head->delay);
    printf("Tokenized2 %s %s %d\n", head->next->cmd, head->next->value, head->next->delay);

    fclose(fp);

The bottom printfs are redundant, I was just testing if it works with classic access to head and via pointer.
Eventually I would like to make this piece of code work.

    const unsigned MAX_LENGTH = 256;
    char cmdbuffer[MAX_LENGTH];
    node_t *head = (node_t *)malloc(sizeof(node_t));
    node_t *hp = head;
    while (fgets(cmdbuffer, MAX_LENGTH, fp)) {
        hp->cmd = strtok(cmdbuffer, ":");
        hp->value = strtok(0, ":");
        hp->delay = atoi(strtok(0, ":"));
        hp->next = (node_t *)malloc(sizeof(node_t));
        hp = (node_t *)hp->next;
    }
    hp->next = NULL;
    printf("Tokenized %s %s %d\n", head->cmd, head->value, head->delay);
    printf("Tokenized2 %s %s %d\n", head->next->cmd, head->next->value, head->next->delay);

How can I solve this problem?

Body:
I managed to solve it with strdup. Here is the code ...

FILE *fp = fopen("commands.txt", "r");

    if (fp == NULL){
        printf("Error: could not open text file");
        return 1;
    }

    const unsigned MAX_LENGTH = 256;
    char cmdbuffer[MAX_LENGTH];
    node_t* head = malloc(sizeof(node_t));
    node_t* hp = head;
    char* sdup;

    while (fgets(cmdbuffer, MAX_LENGTH, fp)){
        sdup = strdup(cmdbuffer);
        hp->cmd = strtok(sdup, ":");
        hp->value = strtok(0, ":");
        hp->delay = atoi(strtok(0, ":"));
        hp->next = malloc(sizeof(node_t));
        hp = (node_t*) hp->next;
    }
    hp->next = NULL;

    hp = head;
    while(hp){
        printf("Tokenized: %s %s %d\n", hp->cmd, hp->value, hp->delay);
        free(hp);
        hp = hp->next;
    }

Comments/corrections are welcome!


问:
Attribute error: module 'collections' has no attribute 'MutableSequence' PYTHON/SMARTSHEET SDK
I installed the Smartsheet Python sdk, imported the smartsheet module but am getting an error when I want to run the script. The error is localized to the smartsheet module and says that collections module is missing Mutable Sequence. I have already tried adding:

```<code>from collections.abc import MutableSequence
</code>```

and had no change.

```<code>import smartsheet
import logging
import os

_dir = os.path.dirname(os.path.abspath(__file__))
</code>```

This is what pops up in the terminal.

```<code> File "C:\Users\jhorvath\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\smartsheet\smartsheet.py", line 34, in <module>
    from .models import Error, ErrorResult
  File "C:\Users\jhorvath\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\smartsheet\models\__init__.py", line 21, in <module>
    from .access_token import AccessToken
  File "C:\Users\jhorvath\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\smartsheet\models\access_token.py", line 20, in <module>
    from ..types import *
  File "C:\Users\jhorvath\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\smartsheet\types.py", line 29, in <module>
    class TypedList(collections.MutableSequence):
AttributeError: module 'collections' has no attribute 'MutableSequence'
</code>```

答: If you are not able to edit the package as recommended in the first solution, use Python 3.9 that is the last version to support collections Mutable Sequence.</p>

Body:
I installed the Smartsheet Python sdk, imported the smartsheet module but am getting an error when I want to run the script. The error is localized to the smartsheet module and says that collections module is missing Mutable Sequence. I have already tried adding:

from collections.abc import MutableSequence

and had no change.

import smartsheet
import logging
import os

_dir = os.path.dirname(os.path.abspath(__file__))

This is what pops up in the terminal.

 File "C:\Users\jhorvath\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\smartsheet\smartsheet.py", line 34, in <module>
    from .models import Error, ErrorResult
  File "C:\Users\jhorvath\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\smartsheet\models\__init__.py", line 21, in <module>
    from .access_token import AccessToken
  File "C:\Users\jhorvath\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\smartsheet\models\access_token.py", line 20, in <module>
    from ..types import *
  File "C:\Users\jhorvath\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\smartsheet\types.py", line 29, in <module>
    class TypedList(collections.MutableSequence):
AttributeError: module 'collections' has no attribute 'MutableSequence'


问:
Adding a dimension to a numpy arrray
I'm working on the MNIST dataset and have my train_x.shape = (60000, 28, 28, ),

but my model requires a shape (60000, 28, 28, 1).

So my questions are:

Why does it have a 'null' dimension instead of just (60000, 28, 28)?

How can I convert the same? Is there some way I can loop through the first dimension in the array? (Or a better solution?)
Thanks in advance!

答:
Good question! I too pondered why it had to be like this when I first started.

Looping through the first dimension can be easily done with

for image in train_x:
    image
```
<p>as looping through NumPy, PyTorch and TensorFlows arrays/tensors will by default just iterate through the "leftmost" axis.</p>
<p>There are multiple ways to add said null dimension to get the shape <code>(60000, 28, 28, 1)</code>:</p>
```train_x[..., None]
train_x[..., np.newaxis]
train_x.reshape((*train_x.shape, 1))
np.expand_dims(train_x, 3)
```

Explanation

Why does it have a 'null' dimension instead of just (60000, 28, 28)?

Generally speaking, when doing image processing you want to be able to handle an arbitrary number of image channels (e.g. RGB channels). Generally, an image dataset is of shape (number of images, height, width, number of channels) (in PyTorch the channels comes before the width and height actually), The MNIST dataset is 1 channel, thus your dataset should have the shape (60000, 28, 28, 1). The frameworks usually implement their code to handle the general case, thus you have to do said reshaping.

Title: Adding a dimension to a numpy arrray

Body:
Good question! I too pondered why it had to be like this when I first started.

Looping through the first dimension can be easily done with

for image in train_x:
    image

as looping through NumPy, PyTorch and TensorFlows arrays/tensors will by default just iterate through the "leftmost" axis.

There are multiple ways to add said null dimension to get the shape (60000, 28, 28, 1):

train_x[..., None]
train_x[..., np.newaxis]
train_x.reshape((*train_x.shape, 1))
np.expand_dims(train_x, 3)

Explanation

Why does it have a 'null' dimension instead of just (60000, 28, 28)?

Generally speaking, when doing image processing you want to be able to handle an arbitrary number of image channels (e.g. RGB channels). Generally, an image dataset is of shape (number of images, height, width, number of channels) (in PyTorch the channels comes before the width and height actually), The MNIST dataset is 1 channel, thus your dataset should have the shape (60000, 28, 28, 1). The frameworks usually implement their code to handle the general case, thus you have to do said reshaping.


问:
Having problem in changing css using useState in react
I'm trying to build a modal in react. When it's opened, the background or the body color must change to a darker one and the modal should open, when closed, everything must go back to normal.
I tried to achieve this by this method:

```<code>const [modalState, setModalState] = useState(false);
const [modalBg, setModalbg] = useState(false);

function handleClick() {
    setModalState(true);
    setModalbg(true);

}
return (
  {
      !modalState ?
       null
       : <Modal modalState = {setModalState}/>
  }
  {
      !modalBg ?
       document.body.style.backgoundColor = "ffff"
      : document.body.style.backgoundColor = 'rgba(39, 38, 38, 0.616)'
  }
  <button onClick= {handleClick}>Open</button>

)
</code>```

The problem is, that instead of changing color of the body, it just renders text to the page like '#fff' or 'red'. I don't know why that happens, can anyone help?

Thanks!

答:
Your way isn't really the "React" way of handling modals. First of all, I can't stress enough the use of portals when creating modals. Do look this up to really understand what portals are and how they help you.

Moving on, you can create a modal component as shown below and trigger this component however you want, using a state. Just make sure to pass the setter of that state to the component as a prop, in my case setShowModal.

Your modal's background is contained in the div my-modal-container and you can change that however you wish.

```<code>import React, { useState, useEffect } from 'react';
import ReactDOM from 'react-dom';

const MyModal = ({setShowModal}) => {

    const handleClose = () => {
        setShowModal(false)
    };

    return ReactDOM.createPortal(
        <div className='my-modal-container'>
            <div class='my-modal-body'>
                //Place all you modal body here
            </div>
        </div>,
        document.getElementById('portal')
    );
};
export default MyModal;
</code>```

If you choose to you use portals as above, make sure you add

 in your index.html file right below

.

Body:
I'm trying to build a modal in react. When it's opened, the background or the body color must change to a darker one and the modal should open, when closed, everything must go back to normal.
I tried to achieve this by this method:

const [modalState, setModalState] = useState(false);
const [modalBg, setModalbg] = useState(false);

function handleClick() {
    setModalState(true);
    setModalbg(true);

}
return (
  {
      !modalState ?
       null
       : <Modal modalState = {setModalState}/>
  }
  {
      !modalBg ?
       document.body.style.backgoundColor = "ffff"
      : document.body.style.backgoundColor = 'rgba(39, 38, 38, 0.616)'
  }
  <button onClick= {handleClick}>Open</button>

)

The problem is, that instead of changing color of the body, it just renders text to the page like '#fff' or 'red'. I don't know why that happens, can anyone help?

Thanks!

Body:
Your way isn't really the "React" way of handling modals. First of all, I can't stress enough the use of portals when creating modals. Do look this up to really understand what portals are and how they help you.

Moving on, you can create a modal component as shown below and trigger this component however you want, using a state. Just make sure to pass the setter of that state to the component as a prop, in my case setShowModal.

Your modal's background is contained in the div my-modal-container and you can change that however you wish.

import React, { useState, useEffect } from 'react';
import ReactDOM from 'react-dom';

const MyModal = ({setShowModal}) => {

    const handleClose = () => {
        setShowModal(false)
    };

    return ReactDOM.createPortal(
        <div className='my-modal-container'>
            <div class='my-modal-body'>
                //Place all you modal body here
            </div>
        </div>,
        document.getElementById('portal')
    );
};
export default MyModal;

If you choose to you use portals as above, make sure you add <div id="portal"></div> in your index.html file right below <div id="root"></div>.