Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsii-runtime-go have json unmarshall issue when execute in parallel #4218

Closed
KaimingWan opened this issue Aug 10, 2023 · 2 comments
Closed
Labels
bug This issue is a bug. closed-for-staleness needs-reproduction This issue needs reproduction. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@KaimingWan
Copy link

Describe the bug

My golang app use tfcdk which depend on jsii, you can ref the code here.

If I run my app and start multi goroutine to execute the core logic, I can find the jsii.Create not work as expected. I debug the code and find err is generated in the following code:

func (p *Process) readResponse(into interface{}) error {
	if !p.responses.More() {
		return fmt.Errorf("no response received from child process")
	}

	var raw json.RawMessage
	var respmap map[string]interface{}
	err := p.responses.Decode(&raw)
	if err != nil {
		return err
	}

	err = json.Unmarshal(raw, &respmap)
	if err != nil {
		return err
	}

	var errResp ErrorResponse
	if _, ok := respmap["error"]; ok {
		json.Unmarshal(raw, &errResp)

		if errResp.Name != nil && *errResp.Name == "@jsii/kernel.Fault" {
			return fmt.Errorf("JsiiError: %s", *errResp.Name)
		}

		return errors.New(errResp.Error)
	}

	return json.Unmarshal(raw, &into)
}

err in p.responses give the json unmarshall error:

invalid character 'j' looking for beginning of value

Is this issue a bug or we can't execute jsii.Create in parallel ?

Expected Behavior

jsii.Create can be executed in parallel

Current Behavior

When execute jsii.Create in parallel, will cause json unmarshall issue

Reproduction Steps

Just startup multi goroutines and init and execute cdktf which will invoke jsii.Create in parallel

Possible Solution

No response

Additional Information/Context

No response

SDK version used

v1.81.0

Environment details (OS name and version, etc.)

5.19.0-0.deb11.2-amd64 #1 SMP PREEMPT_DYNAMIC Debian 5.19.11-1~bpo11+1 (2022-10-03) x86_64 Linux

@KaimingWan KaimingWan added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 10, 2023
@mrgrain
Copy link
Contributor

mrgrain commented Apr 9, 2024

Very likely you can't execute jsii.Create in parallel.

But to help with further debugging, can you provide the code that calls jsii.Create?

@mrgrain mrgrain added needs-reproduction This issue needs reproduction. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Apr 9, 2024
Copy link
Contributor

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. closed-for-staleness needs-reproduction This issue needs reproduction. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants