Skip to content

Commit

Permalink
fix(agent): Playwright Engine Script Name (#3932)
Browse files Browse the repository at this point in the history
* fix(agent): Playwright Engine Script Name

* fix(agent): Playwright Engine Script Name
  • Loading branch information
xoscar committed Jul 10, 2024
1 parent c021dd7 commit 54b5dbb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions agent/workers/trigger/playwrightengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ var (
node = "node"
app = "npx"
// libName = "../../tracetest-js/packages/tracetest-playwright-engine"
libName = "@tracetest/playwright-engine"
scriptPath = "script.js"
libName = "@tracetest/playwright-engine"
baseScriptPath = "script.js"
)

func PLAYWRIGHTENGINE() Triggerer {
Expand All @@ -38,18 +38,19 @@ func (te *playwrightTriggerer) Trigger(ctx context.Context, triggerConfig Trigge
return response, err
}

scriptPath := fmt.Sprintf("%s-%s", opts.TraceID, baseScriptPath)

err = os.WriteFile(scriptPath, []byte(triggerConfig.PlaywrightEngine.Script), 0644)
if err != nil {
return response, err
}

out, err := start(opts.TraceID.String(), opts.SpanID.String(), triggerConfig.PlaywrightEngine.Target, triggerConfig.PlaywrightEngine.Method)
out, err := start(opts.TraceID.String(), opts.SpanID.String(), triggerConfig.PlaywrightEngine.Target, triggerConfig.PlaywrightEngine.Method, scriptPath)
os.Remove(scriptPath)
if err != nil {
os.Remove(scriptPath)
return response, err
}

os.Remove(scriptPath)
response.Result.PlaywrightEngine.Success = true
response.Result.PlaywrightEngine.Out = out
return response, err
Expand All @@ -75,7 +76,7 @@ func validate() error {
return nil
}

func start(traceId, spanId, url, method string) (string, error) {
func start(traceId, spanId, url, method, scriptPath string) (string, error) {
wd, err := os.Getwd()
if err != nil {
return "", err
Expand Down

0 comments on commit 54b5dbb

Please sign in to comment.