Unable to push slices to prismic in slice-machine

Hello! I'm following along on the step by step instructions for using slice machine with next.js here: Developer Documentation - Prismic

I've created a new slice and added an image to it. Added the image to my component and now its showing up in storybook. The next step is to push slice to prismic (so I can add content) and I'm getting the following error in terminal and the push slice to prismic button just hangs. Screenshot: https://nikib.ro/wn/screenshots/localhost9999slicesSimpleHtml_2020-11-23_14-10-32.jpg

[slice-machine] [api/slices] An error occured while fetching slices. Note that when stable, this should break!

[slice-machine] {
  e: TypeError: res.text is not a function
      at _callee2$ (/Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/server/api/push.js:54:35)
      at tryCatch (/Users/nikibrown/Code/my-slicemachine-project/node_modules/regenerator-runtime/runtime.js:63:40)
      at Generator.invoke [as _invoke] (/Users/nikibrown/Code/my-slicemachine-project/node_modules/regenerator-runtime/runtime.js:293:22)
      at Generator.next (/Users/nikibrown/Code/my-slicemachine-project/node_modules/regenerator-runtime/runtime.js:118:21)
      at asyncGeneratorStep (/Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (/Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
}

[slice-machine] (node:262) UnhandledPromiseRejectionWarning: RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined
    at ServerResponse.writeHead (_http_server.js:248:11)
    at ServerResponse._implicitHeader (_http_server.js:239:8)
    at write_ (_http_outgoing.js:642:9)
    at ServerResponse.end (_http_outgoing.js:753:5)
    at ServerResponse.send (/Users/nikibrown/Code/my-slicemachine-project/node_modules/express/lib/response.js:221:10)
    at ServerResponse.json (/Users/nikibrown/Code/my-slicemachine-project/node_modules/express/lib/response.js:267:15)
    at _callee6$ (/Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/server/api/index.js:55:39)
    at tryCatch (/Users/nikibrown/Code/my-slicemachine-project/node_modules/regenerator-runtime/runtime.js:63:40)
    at Generator.invoke [as _invoke] (/Users/nikibrown/Code/my-slicemachine-project/node_modules/regenerator-runtime/runtime.js:293:22)
    at Generator.next (/Users/nikibrown/Code/my-slicemachine-project/node_modules/regenerator-runtime/runtime.js:118:21)
(node:262) 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:262) [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.

Not quite sure how to proceed here. Thanks!

  • N
1 Like

I'm also on the most recent version of the cli: ➜ my-slicemachine-project git:(main) ✗ prismic --version
3.8.3-beta.0

And my apiEndoing is correct: https://dd-slicemachine.cdn.prismic.io/api/v2 (im seeing my pages show up correctly when I run things locally)

I'm also noticing that prismic sm --pull does not pull any of the slices I created on my prismic dashboard as well. Screenshot: https://nikib.ro/wn/screenshots/prismic.js__my-slicemachine-project_2020-11-23_15-18-35.jpg

Hey Niki,

I've seen a similar error before, and I'm working on debugging it. I'll look into it a little more and let you know what I find out!

Sam

UPDATE: December 3, 2020

We have published a troubleshooting guide for issues with Slice Machine setup and development:

I'm having this too - fresh install too if that helps.

Thanks for the quick response!

Since I could not push I made a new slice in my prismic instance and then tried to pull. When I run prismic sm --pull nothing seems to happen besides showing me all the commands:

Screenshot

Hi @niki.brown,

Can you try reinstalling the CLI? Make sure you're on version 3.8.3-beta.0. Then trying logging out and in with prismic logout and prismic login.

@hi11, can you try logging out and in and tell me if that helps?

If push still doesn't work, send me your repo name and your sm.json file (feel free to send it in a DM if you like).

Sam

@niki.brown Yes, that's correct. With SliceBuilder, --pull is now deprecated.

Hi @samlittlefair I just did this an am running into the same error that I posted above.

The contents of my sm.json file:

{
  "libraries": [
    "@/slices",
    "essential-slices"
  ],
  "apiEndpoint": "https://dd-slicemachine.cdn.prismic.io/api/v2",
  "storybook": "http://localhost:8888"
}

And my repo is here https://dd-slicemachine.prismic.io/documents/working/

Re: prismic sm --pull - you might want to remove it from the help documentation if its been deprecated.

You can also find the code I'm using from the tutorial here: https://github.com/nikibrown/my-slicemachine-project

Having the same issue here. Remove prismic-cli, node modules and reinstalled everything. No luck.

@florianberg, could you tell me your repo name? I'll make sure you have the latest version of the slice API activated on our side of things.

Hey Niki,

Could you try updating slice-machine-ui to 0.0.40-alpha.1, and let me know if that makes any difference?

Sam

@samlittlefair I've updated to the new alpha. I can see the updated version in my package.json file:

  "name": "my-slicemachine-project",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "slicemachine": "start-slicemachine --port 9999",
    "storybook": "start-storybook -p 8888",
    "build-storybook": "build-storybook"
  },
  "dependencies": {
    "@emotion/core": "^10.0.5",
    "essential-slices": "0.0.11",
    "next": "10.0.2",
    "next-slicezone": "0.0.10",
    "next-transpile-modules": "^4.1.0",
    "prismic-javascript": "^3.0.2",
    "prismic-reactjs": "^1.3.3",
    "react": "17.0.1",
    "react-dom": "17.0.1"
  },
  "devDependencies": {
    "@storybook/react": "^5.3.19",
    "babel-loader": "^8.2.1",
    "babel-plugin-react-require": "^3.1.3",
    "slice-machine-ui": "0.0.40-alpha.1"
  }
}

Seeing different errors now when I try to push slice to prismic:


> my-slicemachine-project@0.1.0 slicemachine /Users/nikibrown/Code/my-slicemachine-project
> start-slicemachine --port 9999

[slice-machine] Launching server

[slice-machine] Now running on http://localhost:9999 !

[slice-machine] [api/slices] An error occured while fetching slices. Note that when stable, this should break!

[slice-machine] {
  e: Error: ENOENT: no such file or directory, open '/Users/nikibrown/Code/my-slicemachine-project/slices/SimpleHtml/preview.png'
      at Object.openSync (fs.js:458:3)
      at Object.readFileSync (fs.js:360:35)
      at Object.base64Sync (/Users/nikibrown/Code/my-slicemachine-project/node_modules/base64-img/base64-img.js:60:17)
      at _callee2$ (/Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/server/api/push.js:46:34)
      at tryCatch (/Users/nikibrown/Code/my-slicemachine-project/node_modules/regenerator-runtime/runtime.js:63:40)
      at Generator.invoke [as _invoke] (/Users/nikibrown/Code/my-slicemachine-project/node_modules/regenerator-runtime/runtime.js:293:22)
      at Generator.next (/Users/nikibrown/Code/my-slicemachine-project/node_modules/regenerator-runtime/runtime.js:118:21)
      at asyncGeneratorStep (/Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (/Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
      at processTicksAndRejections (internal/process/task_queues.js:97:5) {
    errno: -2,
    syscall: 'open',
    code: 'ENOENT',
    path: '/Users/nikibrown/Code/my-slicemachine-project/slices/SimpleHtml/preview.png'
  }
}

[slice-machine] (node:19972) UnhandledPromiseRejectionWarning: RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined
    at ServerResponse.writeHead (_http_server.js:248:11)
    at ServerResponse._implicitHeader (_http_server.js:239:8)
    at write_ (_http_outgoing.js:642:9)
    at ServerResponse.end (_http_outgoing.js:753:5)
    at ServerResponse.send (/Users/nikibrown/Code/my-slicemachine-project/node_modules/express/lib/response.js:221:10)
    at ServerResponse.json (/Users/nikibrown/Code/my-slicemachine-project/node_modules/express/lib/response.js:267:15)
    at _callee6$ (/Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/server/api/index.js:55:39)
    at tryCatch (/Users/nikibrown/Code/my-slicemachine-project/node_modules/regenerator-runtime/runtime.js:63:40)
    at Generator.invoke [as _invoke] (/Users/nikibrown/Code/my-slicemachine-project/node_modules/regenerator-runtime/runtime.js:293:22)
    at Generator.next (/Users/nikibrown/Code/my-slicemachine-project/node_modules/regenerator-runtime/runtime.js:118:21)
(node:19972) 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: 3)

[slice-machine] (node:19972) [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.```



When I try to edit my slices and add new fields I see this error:

`Could not connect to Storybook. Make sure Storybook is running and its url is set in SliceMachine configuration.` Story book is definitely running when I click on "Open in Storybook"

Thanx Sam!

https://florianberg.prismic.io/

Hey @niki.brown and @florianberg,

We're working on debugging the slice-machine-ui alpha. Niki, it looks like we solved part of the push issue, but now there's an issue with generating previews.

The dev team has released a new version that might address this. Could you try updating to: 0.0.43-alpha.1 and let me know if that helps?

Thanks,
Sam

Thanks @samlittlefair Updated but am running into a bunch of missing babel modules:

➜  my-slicemachine-project git:(main) ✗ prismic sm --develop

> my-slicemachine-project@0.1.0 slicemachine /Users/nikibrown/Code/my-slicemachine-project
> start-slicemachine --port 9999

An error occured while migrating file system. Continuing...
Full error: Error: Cannot find module 'prompts'
Require stack:
- /Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/changelog/common/index.js
- /Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/changelog/versions/0.0.41/index.js
- /Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/changelog/migrate.js
- /Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/start.js
[slice-machine] /Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/server/index.js:1
Error: Cannot find module '@babel/register'
Require stack:
- /Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/server/index.js
    at Object.<anonymous> (/Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/server/index.js:1)
    at Generator.next (<anonymous>) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/server/index.js'
  ]
}

[slice-machine] Thanks for using SliceMachine
➜  my-slicemachine-project git:(main) ✗ prismic sm --develop                  

> my-slicemachine-project@0.1.0 slicemachine /Users/nikibrown/Code/my-slicemachine-project
> start-slicemachine --port 9999

An error occured while migrating file system. Continuing...
Full error: Error: Cannot find module 'prompts'
Require stack:
- /Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/changelog/common/index.js
- /Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/changelog/versions/0.0.41/index.js
- /Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/changelog/migrate.js
- /Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui/start.js
[slice-machine] Launching server

[slice-machine] /Users/nikibrown/Code/my-slicemachine-project/node_modules/resolve/lib/sync.js:1
Error: Cannot find module 'babel-plugin-module-resolver' from '/Users/nikibrown/Code/my-slicemachine-project/node_modules/slice-machine-ui'
    at Function.resolveSync [as sync] (/Users/nikibrown/Code/my-slicemachine-project/node_modules/resolve/lib/sync.js:90:15)
    at resolveStandardizedName (/Users/nikibrown/Code/my-slicemachine-project/node_modules/@babel/core/lib/config/files/plugins.js:101:31)
    at resolvePlugin (/Users/nikibrown/Code/my-slicemachine-project/node_modules/@babel/core/lib/config/files/plugins.js:54:10)
    at loadPlugin (/Users/nikibrown/Code/my-slicemachine-project/node_modules/@babel/core/lib/config/files/plugins.js:62:20)
    at createDescriptor (/Users/nikibrown/Code/my-slicemachine-project/node_modules/@babel/core/lib/config/config-descriptors.js:154:9)
    at /Users/nikibrown/Code/my-slicemachine-project/node_modules/@babel/core/lib/config/config-descriptors.js:109:50
    at Array.map (<anonymous>)
    at createDescriptors (/Users/nikibrown/Code/my-slicemachine-project/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
    at createPluginDescriptors (/Users/nikibrown/Code/my-slicemachine-project/node_modules/@babel/core/lib/config/config-descriptors.js:105:10)
    at plugins (/Users/nikibrown/Code/my-slicemachine-project/node_modules/@babel/core/lib/config/config-descriptors.js:40:19) {
  code: 'MODULE_NOT_FOUND'
}

[slice-machine] Thanks for using SliceMachine

prompts, base64-img, parse-domain, yup, puppeteer, react-icons/bs etc. IS there a way to install all of these that are missing?

Ok I was able to push after installing a ton of things. Now I made an additional change to my slice locally Im unable to push again:

[slice-machine] [push] Unexpected error returned. Server message: request failed with status code 413

I've killed all my processes running, logged out, logged in and and am still running into the error.

The change I made was to add two fields and save things locally: https://nikib.ro/wn/screenshots/localhost9999slicesSimpleHtml_2020-12-01_12-42-04.jpg

Im seeing my changes locally in storybook: https://nikib.ro/wn/screenshots/SimpleHtml_-_Default_slice__Storybook_2020-12-01_12-42-46.jpg

I'm not sure if I'm hijacking this thread, but I am facing [slices API]: Not Found when trying to run prismic sm --develop [slices API]: Not Found and was told to try out a bunch of stuff on this thread and continue the conversation here.

I've logged in and out of the tool but still face [slices API]: Not Found. I read here about having the slice API activated on Prismic's side, is that something that we're missing? our repo is docsportal.prismic.io