mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-13 19:02:15 +01:00
fix(chromium): hypen-data now work everytime
This commit is contained in:
@@ -39,6 +39,7 @@ type browserArguments struct {
|
||||
hostResolverRules string
|
||||
proxyServer string
|
||||
wsUrlReadTimeout time.Duration
|
||||
hyphenDataDirPath string
|
||||
|
||||
// Tasks specific.
|
||||
allowList *regexp2.Regexp
|
||||
@@ -79,6 +80,16 @@ func (b *chromiumBrowser) Start(logger *zap.Logger) error {
|
||||
debug := &debugLogger{logger: logger}
|
||||
b.userProfileDirPath = b.fs.NewDirPath()
|
||||
|
||||
// See https://github.com/gotenberg/gotenberg/issues/1293.
|
||||
err := os.MkdirAll(b.userProfileDirPath, 0o755)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create user profile directory: %w", err)
|
||||
}
|
||||
err = os.Symlink(b.arguments.hyphenDataDirPath, fmt.Sprintf("%s/hyphen-data", b.userProfileDirPath))
|
||||
if err != nil {
|
||||
return fmt.Errorf("create symlink to hyphen-data directory: %w", err)
|
||||
}
|
||||
|
||||
opts := append(chromedp.DefaultExecAllocatorOptions[:],
|
||||
chromedp.CombinedOutput(debug),
|
||||
chromedp.ExecPath(b.arguments.binPath),
|
||||
@@ -93,6 +104,8 @@ func (b *chromiumBrowser) Start(logger *zap.Logger) error {
|
||||
// See https://github.com/gotenberg/gotenberg/issues/1177.
|
||||
chromedp.Flag("no-zygote", true),
|
||||
chromedp.Flag("disable-dev-shm-usage", true),
|
||||
// See https://github.com/gotenberg/gotenberg/issues/1293.
|
||||
chromedp.Flag("disable-component-update", false),
|
||||
)
|
||||
|
||||
if b.arguments.incognito {
|
||||
@@ -133,7 +146,7 @@ func (b *chromiumBrowser) Start(logger *zap.Logger) error {
|
||||
allocatorCtx, allocatorCancel := chromedp.NewExecAllocator(b.initialCtx, opts...)
|
||||
ctx, cancel := chromedp.NewContext(allocatorCtx, chromedp.WithDebugf(debug.Printf))
|
||||
|
||||
err := chromedp.Run(ctx)
|
||||
err = chromedp.Run(ctx)
|
||||
if err != nil {
|
||||
cancel()
|
||||
allocatorCancel()
|
||||
|
||||
Reference in New Issue
Block a user