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

reflex init in an environment without access to the npm registry requires 6 HTTP timeout to complete. #4028

Closed
ndy2 opened this issue Sep 30, 2024 · 0 comments · Fixed by #4082
Labels
bug Something isn't working

Comments

@ndy2
Copy link

ndy2 commented Sep 30, 2024

Describe the bug
Unable to run reflex init in an environment without access to the npm registry.

To Reproduce

FROM SOME_ROCKY_LINUX_BASE_IMAGE:8.8

# Set log level arg/env with default `info`
ARG log_level=info

ADD . /root/
WORKDIR /root

#############################################################
# Pre install Helpers tools from `SOME_PATH` not github.com #
#############################################################
# Install helper tools - Bun
RUN mkdir -p ~/.local/share/reflex/bun/bin
RUN curl -O https://SOME_PATH/bun-linux-x64.zip
RUN unzip bun-linux-x64.zip
RUN mv bun-linux-x64/bun ~/.local/share/reflex/bun/bin
RUN rm -rf bun-linux-x64*

# Install helper tools - fnm with nodejs
RUN mkdir -p ~/.local/share/reflex/fnm/node-versions/v18.17.0/installation
RUN curl -O https://SOME_PATH/fnm-linux.zip
RUN unzip fnm-linux.zip
RUN chmod +x fnm && mv fnm ~/.local/share/reflex/fnm
RUN rm -rf fnm-linux.zip

RUN curl -O https://SOME_PATH/v18.17.0-linux-x64.tar.xz
RUN tar -xf v18.17.0-linux-x64.tar.xz
RUN cp -r node-v18.17.0-linux-x64/* ~/.local/share/reflex/fnm/node-versions/v18.17.0/installation
RUN cp node-v18.17.0-linux-x64/bin/node /usr/local/bin/node
RUN rm -rf *v18.17.0-linux-x64*

######################################################################
# NOT WORKING - it does not effects. Since npm registries are hard coded#
######################################################################
# RUN ~/.local/share/reflex/fnm/node-versions/v18.17.0/installation/bin/npm config set registry `https://SOME-CUSTOM-NPM-REGISTRY/`
# RUN ~/.local/share/reflex/fnm/node-versions/v18.17.0/installation/bin/npm config set strict-ssl false

# install requirements
RUN pip install -r requirements.txt

RUN reflex init --loglevel=debug

ENTRYPOINT ["sleep", "10000000"]
─────────────────────────────────────────────────────── System Info ────────────────────────────────────────────────────────
Debug: Config file: '/usr/local/lib/python3.9/site-packages/reflex/config.py'
Debug: Config: app_name='aiportal' loglevel=<LogLevel.INFO: 'info'> frontend_port=3000 frontend_path='' backend_port=8000 
api_url='http://localhost:8000' deploy_url='http://localhost:3000' backend_host='0.0.0.0' db_url='sqlite:///reflex.db' 
redis_url=None telemetry_enabled=True bun_path='/root/.local/share/reflex/bun/bin/bun' cors_allowed_origins=['*'] 
tailwind={} timeout=120 next_compression=True react_strict_mode=True frontend_packages=[] 
cp_backend_url='https://rxcp-prod-control-plane.fly.dev' cp_web_url='https://control-plane.reflex.run' 
gunicorn_worker_class='uvicorn.workers.UvicornH11Worker' gunicorn_workers=None redis_lock_expiration=10000 
redis_token_expiration=3600
Debug: Running command: ['/root/.local/share/reflex/fnm/node-versions/v18.17.0/installation/bin/node', '-v']
Debug: Running command: ['/root/.local/share/reflex/fnm/fnm', '--version']
Debug: Running command: ['/root/.local/share/reflex/bun/bin/bun', '-v']
Debug: [Reflex 0.6.0 with Python 3.9.13 (PATH: /usr/local/bin/python3.9)]
Debug: [Node 18.17.0 (Expected: 18.17.0) (PATH:/root/.local/share/reflex/fnm/node-versions/v18.17.0/installation/bin/node)]
Debug: [FNM 1.37.1 (Expected: 1.35.1) (PATH: /root/.local/share/reflex/fnm/fnm)]
Debug: [Bun 1.1.10 (Expected: 1.1.10) (PATH: /root/.local/share/reflex/bun/bin/bun)]
Debug: [OS Linux Rocky Linux 8.8 (Green Obsidian)]
Debug: Using package installer at: /root/.local/share/reflex/bun/bin/bun
Debug: Using package executer at: 
/root/.local/share/reflex/fnm/node-versions/v18.17.0/installation/lib/node_modules/npm/bin/npm-cli.js
Debug: Unzip path: /usr/bin/unzip
──────────────────────────────────────────────────── Initializing root ─────────────────────────────────────────────────────
Debug: Running command: ['/root/.local/share/reflex/fnm/node-versions/v18.17.0/installation/bin/node', '-v']
Debug: Running command: ['/root/.local/share/reflex/bun/bin/bun', '-v']
Debug: Skipping node installation as it is already installed.
Debug: Skipping bun installation as it is already installed.
[10:56:26] Initializing the web directory.                                                                    console.py:104
Info: Failed to connect to https://registry.npmjs.org.
Info: Failed to connect to https://registry.npmjs.org.
Info: Failed to connect to https://registry.npmjs.org.
Info: Failed to connect to https://r.cnpmjs.org.
Info: Failed to connect to https://r.cnpmjs.org.
Info: Failed to connect to https://r.cnpmjs.org.
Debug: Setting project hash to 253725660543377905359660071665588858486.
Debug: Creating .gitignore
Debug: Detected encoding for requirements.txt as ascii.
Debug: requirements.txt already has reflex as dependency.
Success: Initialized root

Expected behavior

  • can configure custom npm registry

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

Specifics (please complete the following information):

  • Python Version: 3.9.13
  • Reflex Version: 0.6.0
  • OS: rockylinux 8.8

Additional context
image

  • I found that Improve reflex init and run workflow is in Reflex roadmap 0.7.0 (Reflex Roadmap #2727). Maybe this issue canbe handled in that milestone

  • Related codes - reflex/utils/registry.py

    • registries are hard coded and not configurable
    • latency is always checked three times which requires 6 HTTP timeout for restricted network enviroment.
  • after creating .web manual update of .web/bunfig.toml > install.registry to custom npm registry make me able to reflex run --frontend-only without any issues

@ndy2 ndy2 added the bug Something isn't working label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant