reflex icon indicating copy to clipboard operation
reflex copied to clipboard

error when accessing external to server - Uncaught (in promise) TypeError: Failed to construct 'URL': Invalid URL

Open biobrad opened this issue 1 year ago β€’ 1 comments

Describe the bug

This works fine when using pc run and accessing local host in dev mode, however i have tried to deploy to two separate servers and i get this same issue.

(I also get the issue when using pc run without the --env prod and accessing the server local host)

When attempting to self-host, page loads, but with no functionality. using the command pc run --env prod

Console gives the folllowing error:

(30) Uncaught (in promise) TypeError: Failed to construct 'URL': Invalid URL
    at index-5219258fe035328f.js:1:1921
    at main-0676cfe1c4ae880c.js:1:101925
    at Object.next (main-0676cfe1c4ae880c.js:1:102030)
    at n (613-8edbbe55388aab0d.js:1:78913)
    at a (613-8edbbe55388aab0d.js:1:79116)
    at 613-8edbbe55388aab0d.js:1:79175
    at new Promise (<anonymous>)
    at 613-8edbbe55388aab0d.js:1:79056
    at index-5219258fe035328f.js:1:2220
    at index-5219258fe035328f.js:1:3312

Upon clicking on the error:

   }(), j = function() {
            var e = (0,
            s.Z)((function(e, t, n, r, s, o, i, a) {
                var u;
                return (0,
                c.__generator)(this, (function(c) {
                    return u = new URL(i),                <<<<<<<< errored line
                    e.current = (0,
                    p.ZP)(i, {
                        path: u.pathname,

To Reproduce Steps to reproduce the behavior:

  • Code/Link to Repo: Link below to repo with main configuration file and also pcconfig.py file.
  • https://github.com/biobrad/SLA_Matrix

Expected behavior A clear and concise description of what you expected to happen.

I expected the page to work the same as it does when using dev and localhost

Screenshots If applicable, add screenshots to help explain your problem. image image

** Specifics (please complete the following information):**

  • Python Version: 3.10
  • Pynecone Version: 0.1.19
  • OS: CatOS 8.5 and Ubuntu 22.04
  • Browser (Optional): -chrome or firefox

Additional context Add any other context about the problem here.

Just wanted to say thank you for building pynecone. It is really awesome to be able to get some nodejs functionality into a page with python!

biobrad avatar Mar 21 '23 04:03 biobrad

i just tried with on of the example apps, getting the same error:

image

biobrad avatar Mar 21 '23 09:03 biobrad

Got we will try and recreate and get back to you on this. Is this still erroring in the latest v0.1.20 release?

Alek99 avatar Mar 28 '23 04:03 Alek99

Hi Alek, I think so. Will check again. I really hope it isn't something from my side. I have a less than rudimentary understanding of JS so I apologise for not being able to troubleshoot myself. (I did try though!) Cheers Brad

On Tue, 28 Mar 2023, 3:12 pm Alek Petuskey, @.***> wrote:

Got we will try and recreate and get back to you on this. Is this still erroring in the latest v0.1.20 release?

β€” Reply to this email directly, view it on GitHub https://github.com/pynecone-io/pynecone/issues/714#issuecomment-1486206816, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANITBGXEWNHQMSRFZEWSXRLW6JT35ANCNFSM6AAAAAAWB6B2BE . You are receiving this because you authored the thread.Message ID: @.***>

biobrad avatar Mar 28 '23 04:03 biobrad

Hi Alek, I think so. Will check again. I really hope it isn't something from my side. I have a less than rudimentary understanding of JS so I apologise for not being able to troubleshoot myself. (I did try though!) Cheers Brad …

Ok we will try and recreate this error tomorrow, haven't seen this before but we'll get to the bottom of it.

The UI of your app looks really good! Excited to see it once it's finished!

Alek99 avatar Mar 28 '23 05:03 Alek99

Hi Alek,

It is now working!! it was either one of two things... The version I was using or... I was previously running it in Conda, this time I tried it in a python venv instead.

Thank you for getting back to me.

I am going to have to completely remove my conda environment and re-set it all up. My $PATH is a mess as well, maybe that was also contributing.

I will close this off. (When i get my conda install fixed, i will test again and let you know how I go.)

cheers Brad

biobrad avatar Mar 28 '23 08:03 biobrad

Hmm I'm getting this problem running a local Docker container. It's probably some environment error related to my Dockerfile?

FROM python:3.11-slim as base

RUN adduser --disabled-password pynecone


FROM base as build

WORKDIR /thirdtry
ENV VIRTUAL_ENV=/thirdtry/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

COPY . .

RUN pip install wheel \
    && pip install -r requirements.txt


FROM base as runtime

RUN apt-get update && apt-get install -y \
    curl \
    && curl -fsSL https://deb.nodesource.com/setup_19.x | bash - \
    && apt-get update && apt-get install -y \
    nodejs \
    unzip \
    && rm -rf /var/lib/apt/lists/*

RUN npm install -g n
RUN n latest
RUN npm install -g npm@latest
RUN npm install -g yarn

ENV PATH="/thirdtry/venv/bin:$PATH"


FROM runtime as init

WORKDIR /thirdtry
ENV BUN_INSTALL="/thirdtry/.bun"
COPY --from=build /thirdtry/ /thirdtry/
RUN pc init

RUN yarn install --update-checksums --cwd /thirdtry/.web
RUN yarn add next @emotion/react @chakra-ui/react focus-visible


FROM runtime

COPY --chown=pynecone --from=init /thirdtry/ /thirdtry/
USER pynecone
WORKDIR /thirdtry

CMD ["pc","run" , "--env", "prod"]

EXPOSE 3000
EXPOSE 8000

janzheng avatar Apr 10 '23 10:04 janzheng