Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of undefined (reading 'fallthrough') #5750

Closed
rogadev opened this issue Jul 28, 2022 · 4 comments
Closed

Cannot read properties of undefined (reading 'fallthrough') #5750

rogadev opened this issue Jul 28, 2022 · 4 comments

Comments

@rogadev
Copy link

rogadev commented Jul 28, 2022

Describe the bug

I implemented a Promise.all() in a shadow endpoint that hits 2 different external API endpoints before it combines and returns the data. While the app doesn't seem to be breaking, I am getting the following error in my console when running in development.

Cannot read properties of undefined (reading 'fallthrough')
TypeError: Cannot read properties of undefined (reading 'fallthrough')
    at validate_shadow_output (file:///E:/LocalDevelopmentFiles/viu-fe/svelte/.svelte-kit/runtime/server/index.js:2759:13)
    at load_shadow_data (file:///E:/LocalDevelopmentFiles/viu-fe/svelte/.svelte-kit/runtime/server/index.js:2694:38)      
    at async load_node (file:///E:/LocalDevelopmentFiles/viu-fe/svelte/.svelte-kit/runtime/server/index.js:2285:5)        
    at async respond$1 (file:///E:/LocalDevelopmentFiles/viu-fe/svelte/.svelte-kit/runtime/server/index.js:2986:15)       
    at async resolve (file:///E:/LocalDevelopmentFiles/viu-fe/svelte/.svelte-kit/runtime/server/index.js:3456:11)
    at async respond (file:///E:/LocalDevelopmentFiles/viu-fe/svelte/.svelte-kit/runtime/server/index.js:3392:20)
    at async file:///E:/LocalDevelopmentFiles/viu-fe/svelte/node_modules/@sveltejs/kit/dist/vite.js:1555:22

Reproduction

https://github.com/rogadev/viu-fe/tree/for-svelte-bug

Logs

Cannot read properties of undefined (reading 'fallthrough')
TypeError: Cannot read properties of undefined (reading 'fallthrough')
    at validate_shadow_output (file:///E:/LocalDevelopmentFiles/viu-fe/svelte/.svelte-kit/runtime/server/index.js:2759:13)
    at load_shadow_data (file:///E:/LocalDevelopmentFiles/viu-fe/svelte/.svelte-kit/runtime/server/index.js:2694:38)      
    at async load_node (file:///E:/LocalDevelopmentFiles/viu-fe/svelte/.svelte-kit/runtime/server/index.js:2285:5)        
    at async respond$1 (file:///E:/LocalDevelopmentFiles/viu-fe/svelte/.svelte-kit/runtime/server/index.js:2986:15)       
    at async resolve (file:///E:/LocalDevelopmentFiles/viu-fe/svelte/.svelte-kit/runtime/server/index.js:3456:11)
    at async respond (file:///E:/LocalDevelopmentFiles/viu-fe/svelte/.svelte-kit/runtime/server/index.js:3392:20)
    at async file:///E:/LocalDevelopmentFiles/viu-fe/svelte/node_modules/@sveltejs/kit/dist/vite.js:1555:22

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
    Memory: 67.12 GB / 79.94 GB
  Binaries:
    Node: 18.3.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.5.5 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 103.0.5060.134
    Edge: Spartan (44.19041.1266.0), Chromium (103.0.1264.71)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.64
    @sveltejs/kit: next => 1.0.0-next.396
    svelte: ^3.44.0 => 3.49.0
    vite: ^3.0.0 => 3.0.3

Severity

annoyance

Additional Information

No response

@benmccann
Copy link
Member

@rogadev I cannot access your repository. Please check that it's accessible in an incognito window

@rogadev
Copy link
Author

rogadev commented Jul 29, 2022

Apologies. Give it a go, now.

@rogadev rogadev closed this as completed Jul 29, 2022
@rogadev rogadev reopened this Jul 29, 2022
@rogadev
Copy link
Author

rogadev commented Jul 29, 2022

I haven't had my coffee - I didn't mean to close that. 🤦‍♂️

@rogadev
Copy link
Author

rogadev commented Jul 29, 2022

Here it is.

I made a noob error and didn't actually do anything with the object I created inside the Promise.all(). This makes it work as intended:

return await Promise.all([p1, p2]).then((results) => {
    return {
      status: 200,
      body: {
        noc,
        title: results[1].title,
        jobs: results[1].jobs,
        requirements: results[1].requirements,
        duties: results[1].duties,
        outlook: results[0].outlook,
        outlook_verbose: results[0].outlook_verbose,
        trends: results[0].trends,
        province: 'British Columbia',
        eruid: 5900,
      },
    }
  })

HOWEVER, I would still argue that the error messaging needs work. The way I finally figured out what was going on was this little squiggle at the top of my file which I never even noticed.

image

This finally nudged me to realize that I was just resolving all the promises and then doing absolutely nothing with what that Promise.all() returned.

I hope this is somewhat helpful feedback... 🤷‍♂️

@rogadev rogadev closed this as completed Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants