Skip to content

Commit 54b5dbb

Browse files
authored
fix(agent): Playwright Engine Script Name (#3932)
* fix(agent): Playwright Engine Script Name * fix(agent): Playwright Engine Script Name
1 parent c021dd7 commit 54b5dbb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

agent/workers/trigger/playwrightengine.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ var (
1313
node = "node"
1414
app = "npx"
1515
// libName = "../../tracetest-js/packages/tracetest-playwright-engine"
16-
libName = "@tracetest/playwright-engine"
17-
scriptPath = "script.js"
16+
libName = "@tracetest/playwright-engine"
17+
baseScriptPath = "script.js"
1818
)
1919

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

41+
scriptPath := fmt.Sprintf("%s-%s", opts.TraceID, baseScriptPath)
42+
4143
err = os.WriteFile(scriptPath, []byte(triggerConfig.PlaywrightEngine.Script), 0644)
4244
if err != nil {
4345
return response, err
4446
}
4547

46-
out, err := start(opts.TraceID.String(), opts.SpanID.String(), triggerConfig.PlaywrightEngine.Target, triggerConfig.PlaywrightEngine.Method)
48+
out, err := start(opts.TraceID.String(), opts.SpanID.String(), triggerConfig.PlaywrightEngine.Target, triggerConfig.PlaywrightEngine.Method, scriptPath)
49+
os.Remove(scriptPath)
4750
if err != nil {
48-
os.Remove(scriptPath)
4951
return response, err
5052
}
5153

52-
os.Remove(scriptPath)
5354
response.Result.PlaywrightEngine.Success = true
5455
response.Result.PlaywrightEngine.Out = out
5556
return response, err
@@ -75,7 +76,7 @@ func validate() error {
7576
return nil
7677
}
7778

78-
func start(traceId, spanId, url, method string) (string, error) {
79+
func start(traceId, spanId, url, method, scriptPath string) (string, error) {
7980
wd, err := os.Getwd()
8081
if err != nil {
8182
return "", err

0 commit comments

Comments
 (0)