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

TypeError: Cannot read property 'path' of undefined (v0.14.0 - absolute paths computation on Windows) #91

Closed
somq opened this issue Apr 20, 2021 · 4 comments · Fixed by #94
Labels

Comments

@somq
Copy link

somq commented Apr 20, 2021

Describe the bug

This PR breaks the plugin on Windows because absolute schema paths does not get computed properly.

sls offline start relevant log

# Note: Variables logs of getAppSyncConfig.js
getAppSyncConfig / schemaPaths [ 'graphql/schema.graphql' ]
getAppSyncConfig / basePath D:\_dev\_projects\redacted
globFilePaths / filePaths [ 'graphql/schema.graphql' ]
globFilePaths / basePath D:\_dev\_projects\redacted
globFilePaths / paths []
getAppSyncConfig / schemas []

 Type Error ----------------------------------------------

  TypeError: Cannot read property 'path' of undefined
      at getAppSyncConfig (D:\_dev\_projects\redacted\node_modules\serverless-appsync-simulator\lib\getAppSyncConfig.js:254:38)
      at ServerlessAppSyncSimulator.initServer (D:\_dev\_projects\redacted\node_modules\serverless-appsync-simulator\lib\index.js:85:50)
      at Client.<anonymous> (D:\_dev\_projects\redacted\node_modules\serverless-appsync-simulator\lib\index.js:147:14)
      at Client.emit (events.js:210:5)
      at Client.EventEmitter.emit (domain.js:475:20)
      at BunserBuf.<anonymous> (D:\_dev\_projects\redacted\node_modules\serverless-appsync-simulator\node_modules\fb-watchman\index.js:90:14)
      at BunserBuf.emit (events.js:210:5)
      at BunserBuf.EventEmitter.emit (domain.js:475:20)
      at BunserBuf.process (D:\_dev\_projects\redacted\node_modules\serverless-appsync-simulator\node_modules\bser\index.js:292:10)
      at D:\_dev\_projects\redacted\node_modules\serverless-appsync-simulator\node_modules\bser\index.js:247:12
      at processTicksAndRejections (internal/process/task_queues.js:75:11)

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          win32
     Node Version:              12.14.0
     Framework Version:         2.35.0 (local)
     Plugin Version:            4.5.3
     SDK Version:               4.2.2
     Components Version:        3.8.3

To Reproduce
Run v0.15.0 on Windows

Expected behavior
Absolute schema paths should get computed properly

Additional context

@bboure
Copy link
Member

bboure commented Apr 20, 2021

Thank you @somq for this detailed explanation.

Will try to have a look at this, unfortunately I don't have a windows machine at hand

Related issue: #88 and to some extend, sid88in/serverless-appsync-plugin/issues/404

@somq
Copy link
Author

somq commented Apr 20, 2021

You're welcome @bboure

I checked a bit deeper and it looks like we are not respecting the expected pattern syntax by fast-glob (the dep behind globby)

Quote from fast-glob

⚠️ Always use forward-slashes in glob expressions (patterns and ignore option). Use backslashes for escaping characters.

Our basePath on Windows contains drive letters and backslashes. (e.g. D:\_dev\_projects\redacted)
A solution would be to force-convert paths to POSIX style.
I'd says that a simple .replace with a regex or path.posix would do the job (if we don't want to add another dependency or use)

Edit
This confirms the regex solution; we can follow this recommandation

@somq
Copy link
Author

somq commented Apr 21, 2021

@bboure I can prepare a PR next week when I get to my Windows machine at work
Cheers!

@bboure
Copy link
Member

bboure commented Apr 27, 2021

🎉 This issue has been resolved in version 0.16.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants