-
Notifications
You must be signed in to change notification settings - Fork 475
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
502 badgateway error #506
Comments
hey @superharsha , can you reproduce it every time or is it seemingly random? |
It worked completely fine earlier today, all the sudden I am unable to reach the server. Not sure how to fix, I tried to see the ports running after starting the nextjs server, but the port 3000 was not in use. Now it hasnt worked on my machine or a collaborators since that time. |
Are you talking about an app create with Fragments that was created some time ago and you just shared a URL or does this happen every time you generate a new app with Fragments? Can you please send a video showing the reproduction from start to the finish? |
it looks like the video is too large but heres all the code to reproduce.
On Fri, Dec 13, 2024 at 3:52 PM Harsha Valluri ***@***.***>
wrote:
… Hi Vasek,
Sending the video here for privacy.
Best,
Harsha
On Fri, Dec 13, 2024 at 15:48 Vasek Mlejnsky ***@***.***>
wrote:
> Are you talking about an app create with Fragments that was created some
> time ago and you just shared a URL or does this happen every time you
> generate a new app with Fragments?
>
> Can you please send a video showing the reproduction from start to the
> finish?
>
> —
> Reply to this email directly, view it on GitHub
> <#506 (comment)>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AOSEKCSTACKLSPHRUOBGI2L2FNI2VAVCNFSM6AAAAABTSY2UZGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBSGQZTIOJZGQ>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
I don't think the code was sent |
It should be in the attachments, I’ll copy paste it here:
nextjs_generator.py:
from fastapi import FastAPI, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel, Field
from openai import OpenAI
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
import uvicorn
from dotenv import load_dotenv
from typing import List, Optional, Union, Dict
from e2b_code_interpreter import Sandbox
import logging
import os
# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Load environment variables
load_dotenv()
app = FastAPI()
# Add CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=False,
allow_methods=["*"],
allow_headers=["*"],
)
# Initialize OpenAI client
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
# Constants
SANDBOX_TIMEOUT = 10 * 60 * 1000 # 10 minutes in ms
MAX_DURATION = 60
class CodeFile(BaseModel):
file_path: str
file_content: str
class FragmentSchema(BaseModel):
commentary: str = Field(description="Detailed description of code
generation")
template: str = Field(description="Template identifier", default=
"nextjs-developer")
title: str = Field(description="Short title for the component", max_length=
50)
description: str = Field(description="Brief description", max_length=100)
additional_dependencies: List[str] = Field(default_factory=list, description
="Extra packages needed")
has_additional_dependencies: bool = Field(default=False, description="Whether
additional dependencies are required")
install_dependencies_command: str = Field(default="", description="NPM
install command for additional dependencies")
port: Optional[int] = Field(default=3000, description="Development server
port")
file_path: str = Field(default="app/page.tsx", description="Path to the
main file")
code: Union[str, List[CodeFile]] = Field(description="Generated
TypeScript/Next.js code")
class CodeGenerationRequest(BaseModel):
prompt: str
userID: str = "default-user"
apiKey: Optional[str] = None
class ExecutionResultInterpreter(BaseModel):
sbxId: str
template: str
stdout: str
stderr: str
runtimeError: Optional[str]
cellResults: List[Dict]
class ExecutionResultWeb(BaseModel):
sbxId: str
template: str
url: str
code: str
NEXTJS_TEMPLATES = {
"nextjs-developer": {
"name": "Next.js Developer",
"lib": [
"next",
"react",
"react-dom",
"typescript",
***@***.***/react",
***@***.***/node",
***@***.***/react-dom",
"tailwindcss",
"autoprefixer",
"postcss",
"shadcn-ui"
],
"file": "app/page.tsx",
"instructions": "Next.js 14 app with App Router and TypeScript",
"port": 3000
}
}
@app.post("/generate-nextjs-page")
async def generate_nextjs_page(request: CodeGenerationRequest):
try:
# Get the template details
template = NEXTJS_TEMPLATES.get("nextjs-developer")
# System prompt with template-specific instructions
system_prompt = f"""
You are an expert Next.js developer generating a React component.
Generate a TypeScript React component based on the following template
specifications:
Template Name: {template['name']}
Libraries: {', '.join(template['lib'])}
Main File: {template['file']}
Instructions: {template['instructions']}
Input Prompt: {{prompt}}
Component Generation Rules:
- Use TypeScript
- Use functional components with React hooks
- Use Next.js 14 App Router
- IMPORTANT: Always add "use client" directive at the top of the file when
using React hooks (useState, useEffect, etc.)
- Include Tailwind CSS styling
- Place the component in {template['file']}
- Use libraries: {', '.join(template['lib'])}
- Keep the component simple and focused
- Ensure the component is fully functional
- Add comments explaining the component's purpose
- Handle basic error states
- Remember: Server Components (default in App Router) cannot use hooks - if
using hooks, always add "use client"
Example structure when using hooks:
```tsx
"use client";
// Rest of the component code...
```
"""
# Create the prompt template
prompt = ChatPromptTemplate.from_template(system_prompt)
llm = ChatOpenAI(model="gpt-4o", temperature=0.0)
structured_llm = llm.with_structured_output(FragmentSchema)
chain = prompt | structured_llm
# Generate the fragment
fragment = chain.invoke({
"prompt": f"Generate a Next.js page component for: {request.prompt}"
})
logger.info(f"Fragment generated: {fragment}")
logger.info(f"UserID: {request.userID}")
# Create sandbox
sandbox = Sandbox(
template="nextjs-template-robrilliant25", # Using template name from
e2b.toml
metadata={
"template": 'nextjs-template-robrilliant25',
"userID": request.userID
}
)
# Install packages if needed
if fragment.has_additional_dependencies:
sandbox.commands.run(fragment.install_dependencies_command)
logger.info(
f"Installed dependencies: {', '.join(fragment.additional_dependencies)} in
sandbox"
)
# Copy code to filesystem
if isinstance(fragment.code, list):
for file_item in fragment.code:
sandbox.files.write(file_item.file_path, file_item.file_content)
logger.info(f"Copied file to {file_item.file_path}")
else:
sandbox.files.write(fragment.file_path, fragment.code)
logger.info(f"Copied file to {fragment.file_path}")
# Execute code or return URL based on template
if fragment.template == "code-interpreter-v1":
result = sandbox.run_code(fragment.code if isinstance(fragment.code, str)
else "")
return ExecutionResultInterpreter(
sbxId=sandbox.sandbox_id,
template=fragment.template,
stdout=result.logs.stdout,
stderr=result.logs.stderr,
runtimeError=result.error,
cellResults=result.results
)
else:
sandbox_host = sandbox.get_host(fragment.port or 3000)
sandbox_url = f"https://{sandbox_host}" # Remove port from URL as it's
included in get_host
logger.info(f"Sandbox Base URL: {sandbox_url}")
return ExecutionResultWeb(
sbxId=sandbox.sandbox_id,
template=fragment.template,
url=sandbox_url,
code=fragment.code if isinstance(fragment.code, str) else "\n".join([
file_item.file_content for file_item in fragment.code])
)
except Exception as e:
logger.error(f"Error in code generation: {str(e)}", exc_info=True)
raise HTTPException(status_code=500, detail=str(e))
@app.get("/health")
def health_check():
return {"status": "healthy"}
# This allows running the script directly
if __name__ == "__main__":
uvicorn.run(
"nextjs_generator:app",
host="0.0.0.0",
port=8000,
reload=True
)
…----------------------------------------------------------------------------------------------------------------------------
e2b.Docker:
# You can use most Debian-based base images
FROM node:21-slim
# Install curl and other necessary tools
RUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf
/var/lib/apt/lists/*
COPY compile_page.sh /compile_page.sh
RUN chmod +x /compile_page.sh
# Install dependencies and customize sandbox
WORKDIR /home/user/nextjs-app
# Non-interactive Next.js project creation (removed --no-app flag to use
App Router)
RUN npx ***@***.*** . --ts --tailwind --no-eslint --import-alias
"@/*" --use-npm --no-src-dir --yes
# Non-interactive Shadcn initialization
RUN npx ***@***.*** init -d --yes
# Non-interactive Shadcn component addition
RUN npx ***@***.*** add --all --yes
# Move the Nextjs app to the home directory and remove the nextjs-app
directory
RUN mv /home/user/nextjs-app/* /home/user/ && rm -rf /home/user/nextjs-app
# Install dependencies including tailwindcss-animate
RUN npm install && npm install tailwindcss-animate
# Remove pages directory to avoid routing conflicts with app directory
RUN rm -rf /home/user/pages
----------------------------------------------------------------------------------------------------------------------
compile_page.sh:
#!/bin/bash
# Enable verbose logging
set -x
# Logging function
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
}
# This script runs during building the sandbox template
# and makes sure the Next.js app is (1) running and (2) the `/` page is
compiled
function ping_server() {
log "Starting ping_server function"
counter=0
response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:3000")
while [[ ${response} -ne 200 ]]; do
let counter++
if (( counter % 20 == 0 )); then
log "Waiting for server to start... (Attempt $counter)"
sleep 0.1
fi
response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:3000")
done
log "Server successfully started with 200 response"
}
# Log environment and directory information
log "Current working directory: $(pwd)"
log "Directory contents:"
ls -la
# Log Node.js and npm versions
log "Node.js version: $(node --version)"
log "npm version: $(npm --version)"
# Log current user
log "Current user: $(whoami)"
# Start ping_server in background
ping_server &
# Log before starting Next.js
log "Changing to /home/user directory"
cd /home/user
log "Starting Next.js application with turbo"
npx next --turbo
# Log the exit status
exit_status=$?
log "Next.js application exited with status: $exit_status"
exit $exit_status
----------------------------------------------------------------------------------------------------------------------------------
e2b.toml:
# This is a config for E2B sandbox template.
# You can use 'template_id' (bimmoa8fgbioo46adnhr) or 'template_name
(nextjs-template-robrilliant25) from this config to spawn a sandbox:
# Python SDK
# from e2b import Sandbox
# sandbox = Sandbox(template='nextjs-template-robrilliant25')
# JS SDK
# import { Sandbox } from 'e2b'
# const sandbox = await Sandbox.create({ template:
'nextjs-template-robrilliant25' })
team_id = "0e683eb1-cab0-4f0c-8346-88126fb37fa9"
dockerfile = "e2b.Dockerfile"
template_name = "nextjs-template-robrilliant25"
template_id = "bimmoa8fgbioo46adnhr"
start_command = "/compile_page.sh"
On Fri, Dec 13, 2024 at 16:04 Vasek Mlejnsky ***@***.***>
wrote:
it looks like the video is too large but heres all the code to reproduce.
On Fri, Dec 13, 2024 at 3:52 PM Harsha Valluri *@*.
*> wrote: … <#m_7851908413831420345_m_3019903178362927006_> Hi Vasek,
Sending the video here for privacy. Best, Harsha On Fri, Dec 13, 2024 at
15:48 Vasek Mlejnsky @.*> wrote: > Are you talking about an app create
with Fragments that was created some > time ago and you just shared a URL
or does this happen every time you > generate a new app with Fragments? > >
Can you please send a video showing the reproduction from start to the >
finish? > > — > Reply to this email directly, view it on GitHub > <#506
(comment)
<#506 (comment)>>, or
> unsubscribe >
https://github.com/notifications/unsubscribe-auth/AOSEKCSTACKLSPHRUOBGI2L2FNI2VAVCNFSM6AAAAABTSY2UZGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBSGQZTIOJZGQ
> . > You are receiving this because you were mentioned.Message ID: > *@*.***>
>
I don't think the code was sent
—
Reply to this email directly, view it on GitHub
<#506 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOSEKCRCAE46CCRFBBFCMKT2FNKYLAVCNFSM6AAAAABTSY2UZGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBSGQ2TKNRVHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Is it possible to connect regarding this?
Best,
Harsha
On Fri, Dec 13, 2024 at 16:08 Harsha Valluri ***@***.***>
wrote:
… It should be in the attachments, I’ll copy paste it here:
nextjs_generator.py:
from fastapi import FastAPI, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel, Field
from openai import OpenAI
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
import uvicorn
from dotenv import load_dotenv
from typing import List, Optional, Union, Dict
from e2b_code_interpreter import Sandbox
import logging
import os
# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Load environment variables
load_dotenv()
app = FastAPI()
# Add CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=False,
allow_methods=["*"],
allow_headers=["*"],
)
# Initialize OpenAI client
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
# Constants
SANDBOX_TIMEOUT = 10 * 60 * 1000 # 10 minutes in ms
MAX_DURATION = 60
class CodeFile(BaseModel):
file_path: str
file_content: str
class FragmentSchema(BaseModel):
commentary: str = Field(description="Detailed description of code
generation")
template: str = Field(description="Template identifier", default=
"nextjs-developer")
title: str = Field(description="Short title for the component", max_length
=50)
description: str = Field(description="Brief description", max_length=100)
additional_dependencies: List[str] = Field(default_factory=list,
description="Extra packages needed")
has_additional_dependencies: bool = Field(default=False, description="Whether
additional dependencies are required")
install_dependencies_command: str = Field(default="", description="NPM
install command for additional dependencies")
port: Optional[int] = Field(default=3000, description="Development server
port")
file_path: str = Field(default="app/page.tsx", description="Path to the
main file")
code: Union[str, List[CodeFile]] = Field(description="Generated
TypeScript/Next.js code")
class CodeGenerationRequest(BaseModel):
prompt: str
userID: str = "default-user"
apiKey: Optional[str] = None
class ExecutionResultInterpreter(BaseModel):
sbxId: str
template: str
stdout: str
stderr: str
runtimeError: Optional[str]
cellResults: List[Dict]
class ExecutionResultWeb(BaseModel):
sbxId: str
template: str
url: str
code: str
NEXTJS_TEMPLATES = {
"nextjs-developer": {
"name": "Next.js Developer",
"lib": [
"next",
"react",
"react-dom",
"typescript",
***@***.***/react",
***@***.***/node",
***@***.***/react-dom",
"tailwindcss",
"autoprefixer",
"postcss",
"shadcn-ui"
],
"file": "app/page.tsx",
"instructions": "Next.js 14 app with App Router and TypeScript",
"port": 3000
}
}
@app.post("/generate-nextjs-page")
async def generate_nextjs_page(request: CodeGenerationRequest):
try:
# Get the template details
template = NEXTJS_TEMPLATES.get("nextjs-developer")
# System prompt with template-specific instructions
system_prompt = f"""
You are an expert Next.js developer generating a React component.
Generate a TypeScript React component based on the following template
specifications:
Template Name: {template['name']}
Libraries: {', '.join(template['lib'])}
Main File: {template['file']}
Instructions: {template['instructions']}
Input Prompt: {{prompt}}
Component Generation Rules:
- Use TypeScript
- Use functional components with React hooks
- Use Next.js 14 App Router
- IMPORTANT: Always add "use client" directive at the top of the file when
using React hooks (useState, useEffect, etc.)
- Include Tailwind CSS styling
- Place the component in {template['file']}
- Use libraries: {', '.join(template['lib'])}
- Keep the component simple and focused
- Ensure the component is fully functional
- Add comments explaining the component's purpose
- Handle basic error states
- Remember: Server Components (default in App Router) cannot use hooks -
if using hooks, always add "use client"
Example structure when using hooks:
```tsx
"use client";
// Rest of the component code...
```
"""
# Create the prompt template
prompt = ChatPromptTemplate.from_template(system_prompt)
llm = ChatOpenAI(model="gpt-4o", temperature=0.0)
structured_llm = llm.with_structured_output(FragmentSchema)
chain = prompt | structured_llm
# Generate the fragment
fragment = chain.invoke({
"prompt": f"Generate a Next.js page component for: {request.prompt}"
})
logger.info(f"Fragment generated: {fragment}")
logger.info(f"UserID: {request.userID}")
# Create sandbox
sandbox = Sandbox(
template="nextjs-template-robrilliant25", # Using template name from
e2b.toml
metadata={
"template": 'nextjs-template-robrilliant25',
"userID": request.userID
}
)
# Install packages if needed
if fragment.has_additional_dependencies:
sandbox.commands.run(fragment.install_dependencies_command)
logger.info(
f"Installed dependencies: {', '.join(fragment.additional_dependencies)}
in sandbox"
)
# Copy code to filesystem
if isinstance(fragment.code, list):
for file_item in fragment.code:
sandbox.files.write(file_item.file_path, file_item.file_content)
logger.info(f"Copied file to {file_item.file_path}")
else:
sandbox.files.write(fragment.file_path, fragment.code)
logger.info(f"Copied file to {fragment.file_path}")
# Execute code or return URL based on template
if fragment.template == "code-interpreter-v1":
result = sandbox.run_code(fragment.code if isinstance(fragment.code, str)
else "")
return ExecutionResultInterpreter(
sbxId=sandbox.sandbox_id,
template=fragment.template,
stdout=result.logs.stdout,
stderr=result.logs.stderr,
runtimeError=result.error,
cellResults=result.results
)
else:
sandbox_host = sandbox.get_host(fragment.port or 3000)
sandbox_url = f"https://{sandbox_host}" # Remove port from URL as it's
included in get_host
logger.info(f"Sandbox Base URL: {sandbox_url}")
return ExecutionResultWeb(
sbxId=sandbox.sandbox_id,
template=fragment.template,
url=sandbox_url,
code=fragment.code if isinstance(fragment.code, str) else "\n".join([
file_item.file_content for file_item in fragment.code])
)
except Exception as e:
logger.error(f"Error in code generation: {str(e)}", exc_info=True)
raise HTTPException(status_code=500, detail=str(e))
@app.get("/health")
def health_check():
return {"status": "healthy"}
# This allows running the script directly
if __name__ == "__main__":
uvicorn.run(
"nextjs_generator:app",
host="0.0.0.0",
port=8000,
reload=True
)
----------------------------------------------------------------------------------------------------------------------------
e2b.Docker:
# You can use most Debian-based base images
FROM node:21-slim
# Install curl and other necessary tools
RUN apt-get update && apt-get install -y curl && apt-get clean && rm -rf
/var/lib/apt/lists/*
COPY compile_page.sh /compile_page.sh
RUN chmod +x /compile_page.sh
# Install dependencies and customize sandbox
WORKDIR /home/user/nextjs-app
# Non-interactive Next.js project creation (removed --no-app flag to use
App Router)
RUN npx ***@***.*** . --ts --tailwind --no-eslint
--import-alias "@/*" --use-npm --no-src-dir --yes
# Non-interactive Shadcn initialization
RUN npx ***@***.*** init -d --yes
# Non-interactive Shadcn component addition
RUN npx ***@***.*** add --all --yes
# Move the Nextjs app to the home directory and remove the nextjs-app
directory
RUN mv /home/user/nextjs-app/* /home/user/ && rm -rf /home/user/nextjs-app
# Install dependencies including tailwindcss-animate
RUN npm install && npm install tailwindcss-animate
# Remove pages directory to avoid routing conflicts with app directory
RUN rm -rf /home/user/pages
----------------------------------------------------------------------------------------------------------------------
compile_page.sh:
#!/bin/bash
# Enable verbose logging
set -x
# Logging function
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
}
# This script runs during building the sandbox template
# and makes sure the Next.js app is (1) running and (2) the `/` page is
compiled
function ping_server() {
log "Starting ping_server function"
counter=0
response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:3000")
while [[ ${response} -ne 200 ]]; do
let counter++
if (( counter % 20 == 0 )); then
log "Waiting for server to start... (Attempt $counter)"
sleep 0.1
fi
response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:3000")
done
log "Server successfully started with 200 response"
}
# Log environment and directory information
log "Current working directory: $(pwd)"
log "Directory contents:"
ls -la
# Log Node.js and npm versions
log "Node.js version: $(node --version)"
log "npm version: $(npm --version)"
# Log current user
log "Current user: $(whoami)"
# Start ping_server in background
ping_server &
# Log before starting Next.js
log "Changing to /home/user directory"
cd /home/user
log "Starting Next.js application with turbo"
npx next --turbo
# Log the exit status
exit_status=$?
log "Next.js application exited with status: $exit_status"
exit $exit_status
----------------------------------------------------------------------------------------------------------------------------------
e2b.toml:
# This is a config for E2B sandbox template.
# You can use 'template_id' (bimmoa8fgbioo46adnhr) or 'template_name
(nextjs-template-robrilliant25) from this config to spawn a sandbox:
# Python SDK
# from e2b import Sandbox
# sandbox = Sandbox(template='nextjs-template-robrilliant25')
# JS SDK
# import { Sandbox } from 'e2b'
# const sandbox = await Sandbox.create({ template:
'nextjs-template-robrilliant25' })
team_id = "0e683eb1-cab0-4f0c-8346-88126fb37fa9"
dockerfile = "e2b.Dockerfile"
template_name = "nextjs-template-robrilliant25"
template_id = "bimmoa8fgbioo46adnhr"
start_command = "/compile_page.sh"
On Fri, Dec 13, 2024 at 16:04 Vasek Mlejnsky ***@***.***>
wrote:
> it looks like the video is too large but heres all the code to reproduce.
> On Fri, Dec 13, 2024 at 3:52 PM Harsha Valluri *@*.
>
> *> wrote: …
> <#m_6029077150218459026_m_7851908413831420345_m_3019903178362927006_> Hi
> Vasek, Sending the video here for privacy. Best, Harsha On Fri, Dec 13,
> 2024 at 15:48 Vasek Mlejnsky @.*> wrote: > Are you talking about an app
> create with Fragments that was created some > time ago and you just shared
> a URL or does this happen every time you > generate a new app with
> Fragments? > > Can you please send a video showing the reproduction from
> start to the > finish? > > — > Reply to this email directly, view it on
> GitHub > <#506 (comment)
> <#506 (comment)>>, or
> > unsubscribe >
> https://github.com/notifications/unsubscribe-auth/AOSEKCSTACKLSPHRUOBGI2L2FNI2VAVCNFSM6AAAAABTSY2UZGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBSGQZTIOJZGQ
> > . > You are receiving this because you were mentioned.Message ID: > *@*.***>
> >
>
> I don't think the code was sent
>
> —
> Reply to this email directly, view it on GitHub
> <#506 (comment)>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AOSEKCRCAE46CCRFBBFCMKT2FNKYLAVCNFSM6AAAAABTSY2UZGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBSGQ2TKNRVHA>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
Can you please properly format your code? It's hard for me to get around in it and reproduce the example. Happy to connect, just want to reproduce the example first so I have more points |
I will watch the Python file again here:
…On Fri, Dec 13, 2024 at 16:35 Vasek Mlejnsky ***@***.***> wrote:
Can you please properly format your code? It's hard for me to get around
in it and reproduce the example. Happy to connect, just want to reproduce
the example first so I have more points
—
Reply to this email directly, view it on GitHub
<#506 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOSEKCVM4WNG4K4VVSPWOVT2FNOLNAVCNFSM6AAAAABTSY2UZGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBSGQ4TMNBVG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Or if you send your email here I can share it with you on google
drive, if that works better for you.
On Fri, Dec 13, 2024 at 4:40 PM Harsha Valluri
***@***.***> wrote:
…
I will watch the Python file again here:
On Fri, Dec 13, 2024 at 16:35 Vasek Mlejnsky ***@***.***> wrote:
>
> Can you please properly format your code? It's hard for me to get around in it and reproduce the example. Happy to connect, just want to reproduce the example first so I have more points
>
> —
> Reply to this email directly, view it on GitHub, or unsubscribe.
> You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Yeah, my email is vasek at e2b.dev |
Shared e2b.Dockerfile, e2b.toml, nextjs_generator.py, and I have attached
the compile_page.sh to this email.
On Fri, Dec 13, 2024 at 20:43 Vasek Mlejnsky ***@***.***> wrote:
Yeah, my email is vasek at e2b.dev
—
Reply to this email directly, view it on GitHub
<#506 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOSEKCTA4X2GUXQ5BJ5EPWD2FOLLZAVCNFSM6AAAAABTSY2UZGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBSGY4DKNRUGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
#!/bin/bash
# Enable verbose logging
set -x
# Logging function
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
}
# This script runs during building the sandbox template
# and makes sure the Next.js app is (1) running and (2) the `/` page is compiled
function ping_server() {
log "Starting ping_server function"
counter=0
response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:3000")
while [[ ${response} -ne 200 ]]; do
let counter++
if (( counter % 20 == 0 )); then
log "Waiting for server to start... (Attempt $counter)"
sleep 0.1
fi
response=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:3000")
done
log "Server successfully started with 200 response"
}
# Log environment and directory information
log "Current working directory: $(pwd)"
log "Directory contents:"
ls -la
# Log Node.js and npm versions
log "Node.js version: $(node --version)"
log "npm version: $(npm --version)"
# Log current user
log "Current user: $(whoami)"
# Start ping_server in background
ping_server &
# Log before starting Next.js
log "Changing to /home/user directory"
cd /home/user
log "Starting Next.js application with turbo"
npx next --turbo
# Log the exit status
exit_status=$?
log "Next.js application exited with status: $exit_status"
exit $exit_status
|
I have shared compile_page as well as a docx file insane you didn’t receive
the attachment. Thank you very much for the quick support. You and your
teams effort and innovation is very much appreciated by my team and I!
On Fri, Dec 13, 2024 at 20:46 Harsha Valluri ***@***.***>
wrote:
… Shared e2b.Dockerfile, e2b.toml, nextjs_generator.py, and I have attached
the compile_page.sh to this email.
On Fri, Dec 13, 2024 at 20:43 Vasek Mlejnsky ***@***.***>
wrote:
> Yeah, my email is vasek at e2b.dev
>
> —
> Reply to this email directly, view it on GitHub
> <#506 (comment)>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AOSEKCTA4X2GUXQ5BJ5EPWD2FOLLZAVCNFSM6AAAAABTSY2UZGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNBSGY4DKNRUGM>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
Describe the bug
A clear and concise description of what the bug is.
I am unable to ping my server on fragement. I can run the .sh command to start up my nextjs app in the sandbox and I get
the link that it is running on back as well, but the issue is that I keep getting 502 bad gateway nginx error.
Expected behavior
It worked fine earlier in the day, all the sudden it is giving me an error now when i try to access the server end point in the sandbox.
Browser console output
502 Bad Gateway
nginx/1.27.0
Terminal commands & output
INFO:httpx:HTTP Request: POST https://49983-i7iwe280qistx84jtsi8q-685e4066.e2b.dev/files?path=app%2Fpage.tsx&username=user "HTTP/1.1 200 OK"
INFO:nextjs_generator:Copied file to app/page.tsx
INFO:nextjs_generator:Sandbox Base URL: https://3000-i7iwe280qistx84jtsi8q-685e4066.e2b.dev
The text was updated successfully, but these errors were encountered: