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

[BUG] Cannot read property 'req' of undefined when using serveStatic function #58

Closed
futurelucas4502 opened this issue Aug 17, 2020 · 10 comments · Fixed by #59 or #60
Closed

[BUG] Cannot read property 'req' of undefined when using serveStatic function #58

futurelucas4502 opened this issue Aug 17, 2020 · 10 comments · Fixed by #59 or #60
Assignees
Labels
bug Something isn't working needs investigation Work needs to be done before this can be actioned windows

Comments

@futurelucas4502
Copy link

futurelucas4502 commented Aug 17, 2020

Issue

Setup:

  • Deno Version: 1.3.0
  • v8 Version: 8.6.334
  • Typescript Version: 3.9.7
  • Opine Version: 0.20.2

After following the tutorial for using Opine with dejs here I get an issue where when I try and load the site it gives an error

Not sure if this is relevant but I'm running Windows 10 2004 x64

Details

I installed deno using the following command in powershell: iwr https://deno.land/x/install/install.ps1 -useb | iex

I then followed the tutorial writing out all the code and went to run it using deno run --allow-net --allow-env --allow-read=./ ./entrypoint.ts however if I then try and load the page I get the following error displayed instead of my index page:
image

Exact code used

https://github.com/futurelucas4502/Opine-dejs

@asos-craigmorten asos-craigmorten added bug Something isn't working needs investigation Work needs to be done before this can be actioned labels Aug 17, 2020
@asos-craigmorten asos-craigmorten self-assigned this Aug 17, 2020
@asos-craigmorten
Copy link
Collaborator

asos-craigmorten commented Aug 17, 2020

@futurelucas4502 can you try and confirm you still have an issue after using a --reload flag, e.g.

deno run --allow-net --allow-env --allow-read=./ --reload ./entrypoint.ts

If that fails, can you also see if you have an issue running with the following repo: https://github.com/asos-craigmorten/opine-template. This should be the repository created when following the tutorial.

Let me know how get on?

Edit: Just seen you've posted a repo for reproduction - will give that a go and see if happens for me 🤞


Slightly lost atm as I can't reproduce, but someone else has also had this issue now... This is my setup:

$ deno --version
deno 1.3.0
v8 8.6.334
typescript 3.9.7

on MacOS Mojave (10.14.6), so it could be OS related, but hard to be sure just yet!

@asos-craigmorten
Copy link
Collaborator

Pulled down your repo and it runs ok for me (once realised the default port was 80 not 3000 😂 ). Steps:

mkdir -p ~/git/futurelucas4502
cd ~/git/futurelucas4502
git clone git@github.com:futurelucas4502/Opine-dejs.git
deno run --allow-net --allow-env --allow-read=./ --reload ./entrypoint.ts

Screen Shot 2020-08-17 at 16 05 56

Screen Shot 2020-08-17 at 16 06 02

@asos-craigmorten asos-craigmorten added needs information More information is required before this can be actioned and removed bug Something isn't working needs investigation Work needs to be done before this can be actioned labels Aug 17, 2020
@futurelucas4502
Copy link
Author

futurelucas4502 commented Aug 17, 2020

@asos-craigmorten
I attempted using both the cloned repo and using the reload function the cloned repo is the screenshot below:
image

Using reload on my code is this screenshot:
image

It is certainly an interesting issue because the stylesheets load correctly but we still get an error about the request also if i purposely make a 404 error the page completely loads with details about the 404 error:
image

@futurelucas4502
Copy link
Author

futurelucas4502 commented Aug 17, 2020

So after doing some more research it works completely fine on both Linux and MacOS therefore this seems to be an OS specific issue that only occurs on windows @asos-craigmorten
image

@asos-craigmorten
Copy link
Collaborator

@futurelucas4502 great work confirming! I suspect there may be some path manipulation logic that needs fixing somewhere, that is generally the cause of cross-OS issues

@asos-craigmorten asos-craigmorten changed the title Cannot read property 'req' of undefined when using serveStatic function [BUG] Cannot read property 'req' of undefined when using serveStatic function Aug 18, 2020
@asos-craigmorten asos-craigmorten added bug Something isn't working needs investigation Work needs to be done before this can be actioned windows and removed needs information More information is required before this can be actioned labels Aug 18, 2020
@asos-craigmorten asos-craigmorten linked a pull request Aug 18, 2020 that will close this issue
2 tasks
@asos-craigmorten
Copy link
Collaborator

asos-craigmorten commented Aug 18, 2020

Closed automatically with the linked PR #59

@futurelucas4502 can you confirm whether opine@0.21.1 resolves the issue or whether I've just fixed something unrelated 😂 re-reading here I think it might be the latter... 😅

@asos-craigmorten
Copy link
Collaborator

Ok, I'm able to reproduce under different means on MacOS using the static-files example and navigating to http://localhost:3000/js which invokes the redirect directory listener and then errors with the same message as you have been seeing - will give fixing that a whirl and 🤞 it also solves your issue!

@asos-craigmorten asos-craigmorten linked a pull request Aug 18, 2020 that will close this issue
2 tasks
@asos-craigmorten
Copy link
Collaborator

@futurelucas4502 can you confirm whether opine@0.21.2 resolves the issue?

@futurelucas4502
Copy link
Author

hi @asos-craigmorten thanks for all your work I can confirm opine@0.21.2 fixes the problem and opine now works on windows properly!

@asos-craigmorten
Copy link
Collaborator

That’s awesome to hear! 🍾 please raise further issues if find anything else isn’t quite right 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs investigation Work needs to be done before this can be actioned windows
Projects
None yet
2 participants