Skip to content

Commit af6eea7

Browse files
committed
Merge branch 'main' into cmake-modules
2 parents fcaa136 + b59d782 commit af6eea7

12 files changed

+86
-52
lines changed

.builder/actions/crt_size_check.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def run(self, env):
1111
# Maximum package size (for current platform) in bytes
1212
# NOTE: if you increase this, you might also need to increase the
1313
# limit in continuous-delivery/pack.sh
14-
max_size = 8_250_000
14+
max_size = 9_000_000
1515
# size of current folder
1616
folder_size = 0
1717
# total size in bytes

.github/workflows/ci.yml

+5-11
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ permissions:
2121

2222
jobs:
2323
linux-compat:
24-
runs-on: ubuntu-24.04 # latest
24+
runs-on: ubuntu-22.04 # temporarily downgrade to old ubuntu until https://github.com/actions/runner-images/issues/11471 resolves
2525
strategy:
2626
fail-fast: false
2727
matrix:
@@ -65,30 +65,24 @@ jobs:
6565
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
6666
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ matrix.image }} build -p ${{ env.PACKAGE_NAME }}
6767
68-
linux-musl-armv7:
69-
runs-on: ubuntu-24.04 # latest
68+
linux-musl-armv8:
69+
runs-on: codebuild-aws-crt-nodejs-arm64-${{ github.run_id }}-${{ github.run_attempt }}-arm-3.0-large
7070
strategy:
7171
fail-fast: false
72-
matrix:
73-
image:
74-
- alpine-3.16-x64
7572
steps:
7673
- uses: aws-actions/configure-aws-credentials@v4
7774
with:
7875
role-to-assume: ${{ env.CRT_CI_ROLE }}
7976
aws-region: ${{ env.AWS_DEFAULT_REGION }}
80-
- name: Install qemu/docker
81-
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
8277
- name: Checkout Sources
83-
uses: actions/checkout@v2
78+
uses: actions/checkout@v4
8479
with:
8580
submodules: true
8681
# We can't use the `uses: docker://image` version yet, GitHub lacks authentication for actions -> packages
8782
- name: Build ${{ env.PACKAGE_NAME }}
8883
run: |
89-
export AWS_CRT_ARCH=armv7
9084
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
91-
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-alpine-3.16-armv7 build -p ${{ env.PACKAGE_NAME }}
85+
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-alpine-3.16-arm64 build -p ${{ env.PACKAGE_NAME }}
9286
9387
linux-compiler-compat:
9488
runs-on: ubuntu-24.04 # latest
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: 0.2
2+
phases:
3+
install:
4+
commands:
5+
build:
6+
commands:
7+
- mkdir linux-arm64-musl
8+
- cd aws-crt-nodejs
9+
- ./continuous-delivery/generic-linux-build.sh aws-crt-alpine-3.16-arm64
10+
- cp -r dist/bin/linux-arm64-musl/* ../linux-arm64-musl/
11+
12+
post_build:
13+
commands:
14+
15+
artifacts:
16+
files:
17+
- 'linux-arm64-musl/**/*'
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
IMAGE_NAME=$1
6+
shift
7+
8+
# Pry the builder version this CRT is using out of ci.yml
9+
BUILDER_VERSION=$(cat .github/workflows/ci.yml | grep 'BUILDER_VERSION:' | sed 's/\s*BUILDER_VERSION:\s*\(.*\)/\1/')
10+
echo "Using builder version ${BUILDER_VERSION}"
11+
12+
aws ecr get-login-password | docker login 123124136734.dkr.ecr.us-east-1.amazonaws.com -u AWS --password-stdin
13+
export DOCKER_IMAGE=123124136734.dkr.ecr.us-east-1.amazonaws.com/${IMAGE_NAME}:${BUILDER_VERSION}
14+
15+
export BRANCH_TAG=$(git describe --tags)
16+
docker run --mount type=bind,src=$(pwd),dst=/root/aws-crt-nodejs --env CXXFLAGS $DOCKER_IMAGE --version=${BUILDER_VERSION} build -p aws-crt-nodejs --branch ${BRANCH_TAG} run_tests=false
17+
docker container prune -f

continuous-delivery/pack.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ mkdir $UNZIP
3939
tar -xf aws-crt-$CURRENT_TAG.tgz -C $UNZIP
4040
PACK_FILE_SIZE_KB=$(du -sk $UNZIP | awk '{print $1}')
4141
echo "Current package size: ${PACK_FILE_SIZE_KB}"
42-
if expr $PACK_FILE_SIZE_KB \> "$((27000))" ; then
42+
if expr $PACK_FILE_SIZE_KB \> "$((33000))" ; then
4343
# the package size is too large, return -1
4444
echo "Package size is too large!"
4545
exit -1

lib/common/mqtt.spec.ts

+17-4
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,26 @@ test_env.conditional_test(test_env.AWS_IOT_ENV.mqtt311_is_valid_iot_cred())('MQT
129129
const onMessage = once(connectionWaitingForWill, 'message');
130130
await connectionWaitingForWill.subscribe(willTopic, QoS.AtLeastOnce);
131131

132+
// pause for a couple of seconds to try and minimize chance for a service-side race
133+
await new Promise(resolve => setTimeout(resolve, 2000));
134+
132135
// The third connection that will cause the first one to be disconnected because it has the same client ID.
133136
const connectionDuplicate = await makeConnection(undefined, client_id);
134-
const onConnectDuplicate = once(connectionDuplicate, 'connect');
137+
135138
const onDisconnectDuplicate = once(connectionDuplicate, 'disconnect');
136-
await connectionDuplicate.connect()
137-
const connectDuplicateResult = (await onConnectDuplicate)[0];
138-
expect(connectDuplicateResult).toBeFalsy(); /* session present */
139+
140+
// Rarely, IoT Core disconnects the new connection and not the existing one, so retry in that case
141+
let continueConnecting = true;
142+
while (continueConnecting) {
143+
try {
144+
const onConnectDuplicate = once(connectionDuplicate, 'connect');
145+
await connectionDuplicate.connect();
146+
await onConnectDuplicate;
147+
continueConnecting = false;
148+
} catch (err) {
149+
await new Promise(resolve => setTimeout(resolve, 1000));
150+
}
151+
}
139152

140153
// The second connection should receive Will message after the first connection was kicked out.
141154
const messageReceivedArgs = (await onMessage);

lib/native/mqtt5.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ test_utils.conditional_test(test_utils.ClientEnvironmentalConfig.hasIotCoreEnvir
635635
payload: testPayload
636636
});
637637

638-
await setTimeout(()=>{}, 2000);
638+
await new Promise(resolve => setTimeout(resolve, 2000));
639639

640640
statistics = client.getOperationalStatistics();
641641
expect(statistics.incompleteOperationCount).toBeLessThanOrEqual(0);

source/http_connection.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,12 @@ struct http_connection_binding {
149149
/* finalizer called when node cleans up this object */
150150
static void s_http_connection_from_manager_binding_finalize(napi_env env, void *finalize_data, void *finalize_hint) {
151151
(void)finalize_hint;
152-
(void)env;
153152
struct http_connection_binding *binding = finalize_data;
154153

154+
if (binding->node_external != NULL) {
155+
napi_delete_reference(env, binding->node_external);
156+
}
157+
155158
/* no release call, the http_client_connection_manager has already released it */
156159
aws_mem_release(binding->allocator, binding);
157160
}

source/http_connection_manager.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ struct aws_http_connection_manager *aws_napi_get_http_connection_manager(
2727

2828
static void s_http_connection_manager_finalize(napi_env env, void *finalize_data, void *finalize_hint) {
2929
(void)finalize_hint;
30-
(void)env;
3130
struct http_connection_manager_binding *binding = finalize_data;
31+
if (binding->node_external != NULL) {
32+
napi_delete_reference(env, binding->node_external);
33+
}
3234
aws_mem_release(binding->allocator, binding);
3335
}
3436

source/http_message.c

+15-28
Original file line numberDiff line numberDiff line change
@@ -79,29 +79,29 @@ napi_status aws_napi_http_message_bind(napi_env env, napi_value exports) {
7979

8080
struct http_request_binding {
8181
struct aws_http_message *native;
82-
struct aws_allocator *allocator;
8382

8483
napi_ref node_headers;
8584
};
8685

87-
/* Need a special finalizer to avoid releasing a request object we don't own */
88-
static void s_napi_wrapped_http_request_finalize(napi_env env, void *finalize_data, void *finalize_hint) {
89-
(void)env;
86+
static void s_napi_http_request_finalize(napi_env env, void *finalize_data, void *finalize_hint) {
9087
(void)finalize_hint;
91-
9288
struct http_request_binding *binding = finalize_data;
93-
struct aws_allocator *allocator = binding->allocator;
89+
struct aws_allocator *allocator = aws_napi_get_allocator();
90+
91+
if (binding->node_headers != NULL) {
92+
napi_delete_reference(env, binding->node_headers);
93+
}
9494

95+
aws_http_message_release(binding->native);
9596
aws_mem_release(allocator, binding);
9697
}
9798

9899
napi_status aws_napi_http_message_wrap(napi_env env, struct aws_http_message *message, napi_value *result) {
99100

100101
struct http_request_binding *binding =
101102
aws_mem_calloc(aws_napi_get_allocator(), 1, sizeof(struct http_request_binding));
102-
binding->native = message;
103-
binding->allocator = aws_napi_get_allocator();
104-
return aws_napi_wrap(env, &s_request_class_info, binding, s_napi_wrapped_http_request_finalize, result);
103+
binding->native = aws_http_message_acquire(message);
104+
return aws_napi_wrap(env, &s_request_class_info, binding, s_napi_http_request_finalize, result);
105105
}
106106

107107
struct aws_http_message *aws_napi_http_message_unwrap(napi_env env, napi_value js_object) {
@@ -115,20 +115,6 @@ struct aws_http_message *aws_napi_http_message_unwrap(napi_env env, napi_value j
115115
* Constructor
116116
**********************************************************************************************************************/
117117

118-
static void s_napi_http_request_finalize(napi_env env, void *finalize_data, void *finalize_hint) {
119-
(void)env;
120-
121-
struct http_request_binding *binding = finalize_data;
122-
struct aws_allocator *allocator = finalize_hint;
123-
124-
if (binding->node_headers != NULL) {
125-
napi_delete_reference(env, binding->node_headers);
126-
}
127-
128-
aws_http_message_destroy(binding->native);
129-
aws_mem_release(allocator, binding);
130-
}
131-
132118
static napi_value s_request_constructor(napi_env env, const struct aws_napi_callback_info *cb_info) {
133119

134120
struct aws_allocator *alloc = aws_napi_get_allocator();
@@ -167,7 +153,7 @@ static napi_value s_request_constructor(napi_env env, const struct aws_napi_call
167153
}
168154

169155
napi_value node_this = cb_info->native_this;
170-
AWS_NAPI_CALL(env, napi_wrap(env, node_this, binding, s_napi_http_request_finalize, alloc, NULL), {
156+
AWS_NAPI_CALL(env, napi_wrap(env, node_this, binding, s_napi_http_request_finalize, NULL, NULL), {
171157
napi_throw_error(env, NULL, "Failed to wrap HttpRequest");
172158
goto cleanup;
173159
});
@@ -177,7 +163,7 @@ static napi_value s_request_constructor(napi_env env, const struct aws_napi_call
177163
cleanup:
178164
if (binding) {
179165
if (binding->native) {
180-
aws_http_message_destroy(binding->native);
166+
aws_http_message_release(binding->native);
181167
}
182168
aws_mem_release(alloc, binding);
183169
}
@@ -238,15 +224,16 @@ static napi_value s_request_headers_get(napi_env env, void *native_this) {
238224

239225
napi_value result = NULL;
240226
if (binding->node_headers) {
227+
/* This HTTP request already has a reference to the Node object for the headers */
241228
AWS_NAPI_ENSURE(env, napi_get_reference_value(env, binding->node_headers, &result));
242229
} else {
230+
/* There is no Node object for these headers.
231+
* Create a Node object, and a reference to it, and store that reference on this HTTP request */
243232
struct aws_http_headers *headers = aws_http_message_get_headers(binding->native);
244233
AWS_NAPI_ENSURE(env, aws_napi_http_headers_wrap(env, headers, &result));
234+
AWS_NAPI_ENSURE(env, napi_create_reference(env, result, 1, &binding->node_headers));
245235
}
246236

247-
/* Store the value for later */
248-
AWS_NAPI_ENSURE(env, napi_create_reference(env, result, 1, &binding->node_headers));
249-
250237
return result;
251238
}
252239

source/http_stream.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static void s_on_response_call(napi_env env, napi_value on_response, void *conte
7474
}
7575

7676
/* clean up the response buffer */
77-
aws_http_message_destroy(binding->response);
77+
aws_http_message_release(binding->response);
7878
binding->response = NULL;
7979
}
8080

test/mqtt5.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ export async function subPubUnsubTest(client: mqtt5.Mqtt5Client, qos: mqtt5.QoS,
402402
payload: testPayload
403403
});
404404

405-
await setTimeout(()=>{}, 2000);
405+
await new Promise(resolve => setTimeout(resolve, 2000));
406406

407407
client.stop();
408408
await stopped;
@@ -434,6 +434,9 @@ export async function willTest(publisher: mqtt5.Mqtt5Client, subscriber: mqtt5.M
434434
throw new CrtError("doh");
435435
}
436436

437+
// pause to minimize eventual consistency race condition possibility
438+
await new Promise(resolve => setTimeout(resolve, 1000));
439+
437440
publisher.stop({
438441
reasonCode: mqtt5.DisconnectReasonCode.DisconnectWithWillMessage
439442
});
@@ -659,8 +662,6 @@ export async function doSharedSubscriptionsTest(publisher: mqtt5.Mqtt5Client, su
659662
let messagesReceived : number = 0;
660663
subscriberMessages.forEach(v => {
661664
messagesReceived += v;
662-
// Each subscriber should receive a portion of messages.
663-
expect(v).toBeGreaterThan(0);
664665
});
665666
expect(messagesReceived).toEqual(messagesNumber);
666667

0 commit comments

Comments
 (0)