mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-08 03:07:53 +00:00
fix: add --no-sandbox flag to browser launch options (#6686)
This commit is contained in:
parent
e02ac08089
commit
b6dd6e5210
2 changed files with 79 additions and 24 deletions
|
|
@ -50,15 +50,20 @@ export class UrlContentFetcher {
|
|||
return
|
||||
}
|
||||
const stats = await this.ensureChromiumExists()
|
||||
const args = [
|
||||
"--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
||||
"--disable-dev-shm-usage",
|
||||
"--disable-accelerated-2d-canvas",
|
||||
"--no-first-run",
|
||||
"--disable-gpu",
|
||||
"--disable-features=VizDisplayCompositor",
|
||||
]
|
||||
if (process.platform === "linux") {
|
||||
// Fixes network errors on Linux hosts (see https://github.com/puppeteer/puppeteer/issues/8246)
|
||||
args.push("--no-sandbox")
|
||||
}
|
||||
this.browser = await stats.puppeteer.launch({
|
||||
args: [
|
||||
"--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
||||
"--disable-dev-shm-usage",
|
||||
"--disable-accelerated-2d-canvas",
|
||||
"--no-first-run",
|
||||
"--disable-gpu",
|
||||
"--disable-features=VizDisplayCompositor",
|
||||
],
|
||||
args,
|
||||
executablePath: stats.executablePath,
|
||||
})
|
||||
// (latest version of puppeteer does not add headless to user agent)
|
||||
|
|
|
|||
|
|
@ -125,25 +125,75 @@ describe("UrlContentFetcher", () => {
|
|||
})
|
||||
|
||||
describe("launchBrowser", () => {
|
||||
it("should launch browser with correct arguments", async () => {
|
||||
await urlContentFetcher.launchBrowser()
|
||||
|
||||
expect(vi.mocked(PCR)).toHaveBeenCalledWith({
|
||||
downloadPath: path.join("/test/storage", "puppeteer"),
|
||||
it("should launch browser with correct arguments on non-Linux platforms", async () => {
|
||||
// Ensure we're not on Linux for this test
|
||||
const originalPlatform = process.platform
|
||||
Object.defineProperty(process, 'platform', {
|
||||
value: 'darwin' // macOS
|
||||
})
|
||||
|
||||
const stats = await vi.mocked(PCR).mock.results[0].value
|
||||
expect(stats.puppeteer.launch).toHaveBeenCalledWith({
|
||||
args: [
|
||||
"--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
||||
"--disable-dev-shm-usage",
|
||||
"--disable-accelerated-2d-canvas",
|
||||
"--no-first-run",
|
||||
"--disable-gpu",
|
||||
"--disable-features=VizDisplayCompositor",
|
||||
],
|
||||
executablePath: "/path/to/chromium",
|
||||
try {
|
||||
await urlContentFetcher.launchBrowser()
|
||||
|
||||
expect(vi.mocked(PCR)).toHaveBeenCalledWith({
|
||||
downloadPath: path.join("/test/storage", "puppeteer"),
|
||||
})
|
||||
|
||||
const stats = await vi.mocked(PCR).mock.results[0].value
|
||||
expect(stats.puppeteer.launch).toHaveBeenCalledWith({
|
||||
args: [
|
||||
"--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
||||
"--disable-dev-shm-usage",
|
||||
"--disable-accelerated-2d-canvas",
|
||||
"--no-first-run",
|
||||
"--disable-gpu",
|
||||
"--disable-features=VizDisplayCompositor",
|
||||
],
|
||||
executablePath: "/path/to/chromium",
|
||||
})
|
||||
} finally {
|
||||
// Restore original platform
|
||||
Object.defineProperty(process, 'platform', {
|
||||
value: originalPlatform
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
it("should launch browser with Linux-specific arguments", async () => {
|
||||
// Mock process.platform to be linux
|
||||
const originalPlatform = process.platform
|
||||
Object.defineProperty(process, 'platform', {
|
||||
value: 'linux'
|
||||
})
|
||||
|
||||
try {
|
||||
// Create a new instance to ensure fresh state
|
||||
const linuxFetcher = new UrlContentFetcher(mockContext)
|
||||
await linuxFetcher.launchBrowser()
|
||||
|
||||
expect(vi.mocked(PCR)).toHaveBeenCalledWith({
|
||||
downloadPath: path.join("/test/storage", "puppeteer"),
|
||||
})
|
||||
|
||||
const stats = await vi.mocked(PCR).mock.results[vi.mocked(PCR).mock.results.length - 1].value
|
||||
expect(stats.puppeteer.launch).toHaveBeenCalledWith({
|
||||
args: [
|
||||
"--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
|
||||
"--disable-dev-shm-usage",
|
||||
"--disable-accelerated-2d-canvas",
|
||||
"--no-first-run",
|
||||
"--disable-gpu",
|
||||
"--disable-features=VizDisplayCompositor",
|
||||
"--no-sandbox", // Linux-specific argument
|
||||
],
|
||||
executablePath: "/path/to/chromium",
|
||||
})
|
||||
} finally {
|
||||
// Restore original platform
|
||||
Object.defineProperty(process, 'platform', {
|
||||
value: originalPlatform
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
it("should set viewport and headers after launching", async () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue