Trying to push to prismic new slice

Hi,

Getting these errors when trying to push a new slice created locally to the repository. Have i missed something?

    [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/thokkane/Development/projects/espoon-starwash/node_modules/slice-machine-ui/server/api/push.js:54:35)
      at tryCatch (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:63:40)
      at Generator.invoke [as _invoke] (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:293:22)
      at Generator.next (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:118:21)
      at asyncGeneratorStep (/Users/thokkane/Development/projects/espoon-starwash/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (/Users/thokkane/Development/projects/espoon-starwash/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
}

[slice-machine] (node:68820) UnhandledPromiseRejectionWarning: RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined
    at ServerResponse.writeHead (_http_server.js:241:11)
    at ServerResponse._implicitHeader (_http_server.js:232:8)
    at write_ (_http_outgoing.js:607:9)
    at ServerResponse.end (_http_outgoing.js:717:5)
    at ServerResponse.send (/Users/thokkane/Development/projects/espoon-starwash/node_modules/express/lib/response.js:221:10)
    at ServerResponse.json (/Users/thokkane/Development/projects/espoon-starwash/node_modules/express/lib/response.js:267:15)
    at _callee6$ (/Users/thokkane/Development/projects/espoon-starwash/node_modules/slice-machine-ui/server/api/index.js:55:39)
    at tryCatch (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:63:40)
    at Generator.invoke [as _invoke] (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:293:22)
    at Generator.next (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:118:21)
(node:68820) 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(). (rejection id: 1)
(node:68820) [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.

Hi Riku,

Can you show me the file structure of your Slice folders?

Thanks.

I also seem to have .slicemachine folder
Na╠łytto╠łkuva 2020-11-30 kello 12.48.46

@Phil does this look correct? Only the ProductCard slice is using the new slicemachine. Thats the only one i'm trying to push to the project.

npm packages

    "dependencies": {
    "@nuxtjs/axios": "^5.3.6",
    "@nuxtjs/prismic": "^1.2.4",
    "@prismicio/vue": "^2.0.7",
    "nuxt": "^2.0.0",
    "nuxt-sm": "0.0.6",
    "prismic-javascript": "^3.0.2",
    "vue-essential-slices": "^0.2.0",
    "vue-slicezone": "0.0.26",
    "vuex-map-fields": "^1.4.1"
  },
  "devDependencies": {
    "@fortawesome/fontawesome-free": "^5.14.0",
    "@nuxtjs/dotenv": "^1.4.1",
    "@nuxtjs/storybook": "^2.2.2",
    "@nuxtjs/vuetify": "^1.0.0",
    "core-js": "^3.8.0",
    "node-sass": "^4.14.1",
    "sass-loader": "^8.0.0",
    "slice-machine-ui": "0.0.40-alpha.1"
  }

Also, in the previously pasted code, I had manually pasted a preview image to the slice folder. If i don't do that, then the preview image is not found giving these errors:

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

[slice-machine] (node:72764) UnhandledPromiseRejectionWarning: RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined
    at ServerResponse.writeHead (_http_server.js:241:11)
    at ServerResponse._implicitHeader (_http_server.js:232:8)
    at write_ (_http_outgoing.js:607:9)
    at ServerResponse.end (_http_outgoing.js:717:5)
    at ServerResponse.send (/Users/thokkane/Development/projects/espoon-starwash/node_modules/express/lib/response.js:221:10)
    at ServerResponse.json (/Users/thokkane/Development/projects/espoon-starwash/node_modules/express/lib/response.js:267:15)
    at _callee6$ (/Users/thokkane/Development/projects/espoon-starwash/node_modules/slice-machine-ui/server/api/index.js:55:39)
    at tryCatch (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:63:40)
    at Generator.invoke [as _invoke] (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:293:22)
    at Generator.next (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:118:21)

[slice-machine] (node:72764) 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(). (rejection id: 1)
(node:72764) [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.

I've also logged out and in multiple times.

It seems locally i can add fields fine, but pushing to the server doesn't work. Can you check that our project is running on the latest slicemachine?

Hey Riku,

There's only one version of Slicemachine, so that's ok. I think this might be due to changes we made with the preview image in the project. I'm talking with the team and I'll let you know once we figure this out.

Hi Riku,

Can you try uninstalling and re-installing the slicemachine-ui dependency?

Thanks.

Hi

Didn't help. Here's exactly what i did and what i get at the moment in terminal

Did following

  1. npm uninstall slice-machine-ui

  2. npm install slice-machine-ui => package.json shows 0.0.42

  3. prismic logout

  4. prismic login

  5. prismic sm --create-slice --framework nuxt => slice name TestSlice

  6. npm run storybook (terminal tab 1)

  7. prismic sm --develop (terminal tab 2)

  8. then when I click "Push Slice to Prismic" in slice machine ui i get this:

     [slice-machine] {
       e: Error: ENOENT: no such file or directory, open '/Users/thokkane/Development/projects/espoon-starwash/slices/TestSlice/preview.png'
           at Object.openSync (fs.js:440:3)
           at Object.readFileSync (fs.js:342:35)
           at Object.base64Sync (/Users/thokkane/Development/projects/espoon-starwash/node_modules/base64-img/base64-img.js:60:17)
           at _callee2$ (/Users/thokkane/Development/projects/espoon-starwash/node_modules/slice-machine-ui/server/api/push.js:46:34)
           at tryCatch (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:63:40)
           at Generator.invoke [as _invoke] (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:293:22)
           at Generator.next (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:118:21)
           at asyncGeneratorStep (/Users/thokkane/Development/projects/espoon-starwash/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
           at _next (/Users/thokkane/Development/projects/espoon-starwash/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
           at processTicksAndRejections (internal/process/task_queues.js:93:5) {
         errno: -2,
         syscall: 'open',
         code: 'ENOENT',
         path: '/Users/thokkane/Development/projects/espoon-starwash/slices/TestSlice/preview.png'
       }
     }
    
     [slice-machine] (node:81137) UnhandledPromiseRejectionWarning: RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined
         at ServerResponse.writeHead (_http_server.js:241:11)
         at ServerResponse._implicitHeader (_http_server.js:232:8)
         at write_ (_http_outgoing.js:607:9)
         at ServerResponse.end (_http_outgoing.js:717:5)
         at ServerResponse.send (/Users/thokkane/Development/projects/espoon-starwash/node_modules/express/lib/response.js:221:10)
         at ServerResponse.json (/Users/thokkane/Development/projects/espoon-starwash/node_modules/express/lib/response.js:267:15)
         at _callee6$ (/Users/thokkane/Development/projects/espoon-starwash/node_modules/slice-machine-ui/server/api/index.js:55:39)
         at tryCatch (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:63:40)
         at Generator.invoke [as _invoke] (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:293:22)
         at Generator.next (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:118:21)
    
     [slice-machine] (node:81137) 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(). (rejection id: 1)
     (node:81137) [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.
    

If i copy the preview image from ".slicemachine/assets/slices"/TestSlice/preview.png to the actual slice folder, then the "no such file error" disappears but then i get this:

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

[slice-machine] (node:81524) UnhandledPromiseRejectionWarning: RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: undefined
    at ServerResponse.writeHead (_http_server.js:241:11)
    at ServerResponse._implicitHeader (_http_server.js:232:8)
    at write_ (_http_outgoing.js:607:9)
    at ServerResponse.end (_http_outgoing.js:717:5)
    at ServerResponse.send (/Users/thokkane/Development/projects/espoon-starwash/node_modules/express/lib/response.js:221:10)
    at ServerResponse.json (/Users/thokkane/Development/projects/espoon-starwash/node_modules/express/lib/response.js:267:15)
    at _callee6$ (/Users/thokkane/Development/projects/espoon-starwash/node_modules/slice-machine-ui/server/api/index.js:55:39)
    at tryCatch (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:63:40)
    at Generator.invoke [as _invoke] (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:293:22)
    at Generator.next (/Users/thokkane/Development/projects/espoon-starwash/node_modules/regenerator-runtime/runtime.js:118:21)

[slice-machine] (node:81524) 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(). (rejection id: 1)
(node:81524) [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.

I'm not really sure what the issue could be. Can you zip up the project and send it to me or send me a github link? I'll try to look further in to it.

Did you have any more luck with this?

This issue has been closed due to inactivity. Flag to reopen.