Error using playwright on project

I´ve trying to deploy my scraping server, but the railway faild building e deploying here is the log system and my dependencies in package json I have authorization to scrapy, plus it's public data "dependencies": { "axios": "^1.6.8", "dotenv": "^16.4.5", "env-var": "^7.4.1", "fs": "^0.0.1-security", "jsdom": "^24.0.0", "node-cron": "^3.0.3", "node-schedule": "^2.1.1", "nodemailer": "^6.9.13", "openai": "^4.29.2", "pg": "^8.11.3", "playwright": "^1.42.1", "prompt-sync": "^4.2.0", "sequelize": "^6.37.1" }
63 Replies
Percy
Percy3mo ago
Project ID: 90126b32-7716-4f6e-8326-00312abc6db6
Luis Kurihara
Luis Kurihara3mo ago
90126b32-7716-4f6e-8326-00312abc6db6
Brody
Brody3mo ago
I can not recommend using browserless enough, using it means you don't have to install chrome/chromium and all of its needed dependencies into your container, this will significantly speed up both the build and the publishing stage. Browserless template here - https://railway.app/template/browserless And here's my little example repo that shows you how to use browserless with playwright - https://github.com/brody192/playwright-example
Luis Kurihara
Luis Kurihara3mo ago
ok but
Brody
Brody3mo ago
but?
Luis Kurihara
Luis Kurihara3mo ago
where i can find this env WS_ENDPOINT_PLAYWRIGHT=${{Browserless.WS_ENDPOINT_PLAYWRIGHT}} this 'WS_ENDPOINT_PLAYWRIGHT" the template do it?
Brody
Brody3mo ago
yes that's provided by the template
Luis Kurihara
Luis Kurihara3mo ago
okayy i will try how i can use this template? just click on 'Deploy Now'? i never use template on railway
Brody
Brody3mo ago
nope, open your pre-existing project and click the + New button and search for the template
Luis Kurihara
Luis Kurihara3mo ago
okay and click deploy?
Brody
Brody3mo ago
yes, as long as you follow my instructions
Luis Kurihara
Luis Kurihara3mo ago
No description
Brody
Brody3mo ago
looks good!
Luis Kurihara
Luis Kurihara3mo ago
and just change like this: const browser = await playwright.chromium.connect(process.env.WS_ENDPOINT_PLAYWRIGHT);
Brody
Brody3mo ago
yep that looks right you'd also want to remove your custom build command that tries to install chrome
Luis Kurihara
Luis Kurihara3mo ago
hey brody good night, I ended up leaving home and only returned now same error using browserless
Brody
Brody3mo ago
build logs please
Brody
Brody3mo ago
okay and show me your playwright.chromium code please
Brody
Brody3mo ago
are you sure you arent calling chromium.launch elsewhere?
Luis Kurihara
Luis Kurihara3mo ago
yes, have other functions all i ve changed but this are the first
Brody
Brody3mo ago
your code is still trying to launch chrome
Luis Kurihara
Luis Kurihara3mo ago
and have the error Do I have to set up any ENV variables? this WS_ENDPOINT_PLAYWRIGHT
Brody
Brody3mo ago
yes you do, please read the readme
Luis Kurihara
Luis Kurihara3mo ago
WS_ENDPOINT_PLAYWRIGHT=${{Browserless.WS_ENDPOINT_PLAYWRIGHT}} this correct?
Brody
Brody3mo ago
yes, that needs to be set on your app's service
Luis Kurihara
Luis Kurihara3mo ago
but i dont use app service i will send you my main.js it is simple bot
Luis Kurihara
Luis Kurihara3mo ago
look just a cron who will run everyday
Brody
Brody3mo ago
instead of typing out the name of the service you use i simply said app as a generic cover, i am talking about the service in the top left of this screenshot
No description
Luis Kurihara
Luis Kurihara3mo ago
broo I don't believe it
Brody
Brody3mo ago
what?
Luis Kurihara
Luis Kurihara3mo ago
I went to check the variable and it was missing a point
Brody
Brody3mo ago
that would be an issue
Luis Kurihara
Luis Kurihara3mo ago
I changed it and now it's gone I'm sorry how i can pay you? for this help
Brody
Brody3mo ago
theres no need for pay lol
Luis Kurihara
Luis Kurihara3mo ago
okay i ve looking for browserless website
Brody
Brody3mo ago
i appreciate the offer though ❤️
Luis Kurihara
Luis Kurihara3mo ago
and i saw the 'pricing'
Brody
Brody3mo ago
well now you are self-hosting it, so you only have to pay railway's usage pricing
Luis Kurihara
Luis Kurihara3mo ago
okay thats right I don't know if you noticed, but I'm from Brazil so bad English ahaha
Brody
Brody3mo ago
nah your english is fine
Luis Kurihara
Luis Kurihara3mo ago
this is common? to much issues now
Brody
Brody3mo ago
is your service not working?
Luis Kurihara
Luis Kurihara3mo ago
yes
Brody
Brody3mo ago
then the logs are normal
Luis Kurihara
Luis Kurihara3mo ago
are closing the browser the internet are slow on railway? i have to change the 'waitforselector'? look this line 'page.waitForTimeout: page.waitForSelector: page.waitForSelector: Target page, context or browser has been closed'
Brody
Brody3mo ago
browserless closes its chromium browser when not in use to save on resources
Luis Kurihara
Luis Kurihara3mo ago
but it was in 100% use, i didn't understand mt well i'm going to change the codes and test again
Brody
Brody3mo ago
each call to chromium.connect would spawn another browser and then it would get closed, if your service works fine, then theres nothing to worry about
Luis Kurihara
Luis Kurihara3mo ago
my service isn't working it's taking 1/8 of the data
Brody
Brody3mo ago
im not sure what "1/8 of the data" means
Luis Kurihara
Luis Kurihara3mo ago
it is dosent working hahaha i dont know why the browser are closing i will put more time between functions
Brody
Brody3mo ago
the browser is closing because they did what your code asked them to do
Luis Kurihara
Luis Kurihara3mo ago
running here on my computer locally it works now online it closes
Brody
Brody3mo ago
thats how browserless works
Luis Kurihara
Luis Kurihara3mo ago
same issues here i dont know what is going on beacuse the page are open and the console show this issues: page.waitForTimeout: page.waitForTimeout: page.waitForTimeout: page.waitForTimeout: page.waitForTimeout: page.waitForTimeout: page.waitForTimeout: page.waitForSelector: page.waitForSelector: page.waitForSelector: page.waitForSelector: Target page, context or browser has been closed at links (/app/pegarlinks_caixa.js:59:24) at /app/async file:/app/test.js:23:29 i ve put a console.log if page are closed
Brody
Brody3mo ago
okay but is that causing your app to not work correctly?
Luis Kurihara
Luis Kurihara3mo ago
Yes, as it is a site that takes a long time to load there are waitforselector with very long timeouts how can i change in browserless to stay more on the page?
Brody
Brody3mo ago
browserless has it's timeout set at 5 minutes, I can't see you needing more than that