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

Callback into behavioral interface implementation fails from async context #3917

Open
mrgrain opened this issue Jan 20, 2023 · 0 comments · May be fixed by #3919
Open

Callback into behavioral interface implementation fails from async context #3917

mrgrain opened this issue Jan 20, 2023 · 0 comments · May be fixed by #3919
Assignees
Labels
bug This issue is a bug. p2

Comments

@mrgrain
Copy link
Contributor

mrgrain commented Jan 20, 2023

Describe the bug

Given the following code:

#!/usr/bin/env python3
import builtins
import typing
import jsii
import aws_cdk as cdk
import aws_cdk.aws_sqs as sqs
from aws_cdk.cli_lib_alpha import AwsCdkCli, ICloudAssemblyDirectoryProducer

@jsii.implements(ICloudAssemblyDirectoryProducer)
class CliProducer:
    def produce(self, context: typing.Mapping[builtins.str, typing.Any]) -> builtins.str:
        app = cdk.App()
        stack = cdk.Stack(app, 'Default')
        sqs.Queue(stack, 'Queue')
        return app.synth().directory


cli = AwsCdkCli.from_cloud_assembly_directory_producer(producer=CliProducer())
cli.list()

Current Behavior

jsii fails with

  File "/Users/abc/.pyenv/versions/3.10.5/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Exception ignored in atexit callback: <bound method _NodeProcess.stop of <jsii._kernel.providers.process._NodeProcess object at 0x10c53ffd0>>
Traceback (most recent call last):
  File "/Users/abc/code/scratchpad/cli-lib/python/.venv/lib/python3.10/site-packages/jsii/_kernel/providers/process.py", line 295, in stop
    self._process.stdin.close()
BrokenPipeError: [Errno 32] Broken pipe

Reproduction Steps

Using these requirements.txt:

aws-cdk-lib==2.61.0
constructs>=10.0.0,<11.0.0
pytest==6.2.5
black>=22.6.0
aws-cdk.cli-lib-alpha==2.61.0a0

Possible Solution

No response

Additional Information/Context

Last part of JSII_DEBUG just before the error:

[@jsii/kernel] callbacks
< {"ok":{"callbacks":[]}}
> {"promiseid":"jsii::promise::20000","api":"end"}
[@jsii/kernel] end jsii::promise::20000
waiting for promise to be fulfilled
[@jsii/kernel] invoke async method override { method: 'produce', property: null, cookie: 'produce' }
[@jsii/kernel] deserialize {
  'aws:cdk:enable-path-metadata': true,
  'aws:cdk:enable-asset-metadata': true,
  'aws:cdk:version-reporting': true,
  'aws:cdk:bundling-stacks': []
} [
  {
    serializationClass: 'Map',
    typeRef: { name: 'context', type: [Object] }
  }
]
[@jsii/kernel] deserialize true [ { serializationClass: 'Any', typeRef: { type: [Object] } } ]
[@jsii/kernel] ANY is a Scalar
[@jsii/kernel] deserialize true [ { serializationClass: 'Any', typeRef: { type: [Object] } } ]
[@jsii/kernel] ANY is a Scalar
[@jsii/kernel] deserialize true [ { serializationClass: 'Any', typeRef: { type: [Object] } } ]
[@jsii/kernel] ANY is a Scalar
[@jsii/kernel] deserialize [] [ { serializationClass: 'Any', typeRef: { type: [Object] } } ]
[@jsii/kernel] ANY is an Array
[@jsii/kernel] adding callback to queue jsii::callback::20001

SDK version used

jsii-1.73.0

Environment details (OS name and version, etc.)

MacOS

@mrgrain mrgrain added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 20, 2023
@mrgrain mrgrain changed the title (short issue description) Callback into behavioral interface implementation fails from async context Jan 20, 2023
@mrgrain mrgrain self-assigned this Jul 7, 2023
@mrgrain mrgrain added p2 and removed needs-triage This issue or PR still needs to be triaged. labels Apr 9, 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. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant