Skip to content

K6 can not resolve imports in siblings of parent directory #5176

@jeroenhuinink

Description

@jeroenhuinink

Brief summary

K6 does not resolve imports in siblings of the parent directory.

The following is the minimal reproduction:

  • create a file: 1/test.ts that imports a function from 2/lib.ts.
  • from the root directory (the one containing dirs 1 and 2) run the command: k6 run 1/test.ts then the script starts and runs as expected.
  • when you go into directory 1 and run the command k6 run test.ts you get the following error:
ERRO[0000] Automatic extension resolution is enabled but it failed to analyze the dependencies. Please, make sure to report this issue by opening a bug report.  error="test.ts:1:20 opening file via launcher's bridge: open 2/lib.ts: Het systeem kan het opgegeven pad niet vinden."
ERRO[0000] test.ts:1:20 opening file via launcher's bridge: open 2/lib.ts: Het systeem kan het opgegeven pad niet vinden.

The error message in dutch Het systeem kan het opgegeven pad niet vinden. means The system can not find the file specified.

This bug was introduced in 1.2.3. It works in 1.2.2.

k6 version

1.2.3

OS

Windows 11

Docker version and image (if applicable)

No response

Steps to reproduce the problem

  • create a file: 1/test.ts that imports a function from ../2/lib.ts.
    E.g.:
import { lib } from '../2/lib.ts';

export default function () {
    lib();
    console.log('test');
}
export function lib() {
    console.log('lib');
}
  • go to directory 1 and run k6 run test.ts from the commandline.

Expected behaviour

k6 resolves the dependencies and runs the script.

Expected output:


         /\      Grafana   /‾‾/  
    /\  /  \     |\  __   /  /   
   /  \/    \    | |/ /  /   ‾‾\ 
  /          \   |   (  |  (‾)  |
 / __________ \  |_|\_\  \_____/ 

     execution: local
        script: test.ts
        output: -

     scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
              * default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)

INFO[0000] lib                                           source=console
INFO[0000] test                                          source=console


  █ TOTAL RESULTS

    EXECUTION
    iteration_duration...: avg=1ms min=1ms med=1ms max=1ms p(90)=1ms p(95)=1ms
    iterations...........: 1   995.321987/s

    NETWORK
    data_received........: 0 B 0 B/s
    data_sent............: 0 B 0 B/s




running (00m00.0s), 0/1 VUs, 1 complete and 0 interrupted iterations
default ✓ [======================================] 1 VUs  00m00.0s/10m0s  1/1 iters, 1 per VU

Actual behaviour

You get the error:

ERRO[0000] Automatic extension resolution is enabled but it failed to analyze the dependencies. Please, make sure to report this issue by opening a bug report.  error="test.ts:1:20 opening file via launcher's bridge: open 2/lib.ts: Het systeem kan het opgegeven pad niet vinden."
ERRO[0000] test.ts:1:20 opening file via launcher's bridge: open 2/lib.ts: Het systeem kan het opgegeven pad niet vinden.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions