Skip to content

Commit 98615af

Browse files
committed
Address comments
1 parent cbdda2d commit 98615af

3 files changed

Lines changed: 22 additions & 39 deletions

File tree

.github/workflows/linux-arm64-build-and-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ jobs:
6161
source /opt/ros/${{ matrix.ros_distribution }}/setup.bash
6262
npm i
6363
npm test
64+
npm run clean

lib/client.js

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
const rclnodejs = require('./native_loader.js');
1818
const DistroUtils = require('./distro.js');
1919
const Entity = require('./entity.js');
20-
const {
21-
TypeValidationError,
22-
TimeoutError,
23-
AbortError,
24-
} = require('./errors.js');
2520
const debug = require('debug')('rclnodejs:client');
2621

2722
// Polyfill for AbortSignal.any() for Node.js <= 20.3.0
@@ -101,10 +96,7 @@ class Client extends Entity {
10196
*/
10297
sendRequest(request, callback) {
10398
if (typeof callback !== 'function') {
104-
throw new TypeValidationError('callback', callback, 'function', {
105-
entityType: 'service',
106-
entityName: this._serviceName,
107-
});
99+
throw new TypeError('Invalid argument');
108100
}
109101

110102
let requestToSend =
@@ -125,8 +117,8 @@ class Client extends Entity {
125117
* @param {number} [options.timeout] - Timeout in milliseconds for the request.
126118
* @param {AbortSignal} [options.signal] - AbortSignal to cancel the request.
127119
* @return {Promise<object>} Promise that resolves with the service response.
128-
* @throws {module:rclnodejs.TimeoutError} If the request times out (when options.timeout is exceeded).
129-
* @throws {module:rclnodejs.AbortError} If the request is manually aborted (via options.signal).
120+
* @throws {TimeoutError} If the request times out (when options.timeout is exceeded).
121+
* @throws {AbortError} If the request is manually aborted (via options.signal).
130122
* @throws {Error} If the request fails for other reasons.
131123
*/
132124
sendRequestAsync(request, options = {}) {
@@ -160,31 +152,31 @@ class Client extends Entity {
160152

161153
if (effectiveSignal) {
162154
if (effectiveSignal.aborted) {
163-
const error = isTimeout
164-
? new TimeoutError('Service request', options.timeout, {
165-
entityType: 'service',
166-
entityName: this._serviceName,
167-
})
168-
: new AbortError('Service request', undefined, {
169-
entityType: 'service',
170-
entityName: this._serviceName,
171-
});
155+
const error = new Error(
156+
isTimeout
157+
? `Request timeout after ${options.timeout}ms`
158+
: 'Request was aborted'
159+
);
160+
error.name = isTimeout ? 'TimeoutError' : 'AbortError';
161+
if (isTimeout) {
162+
error.code = 'TIMEOUT';
163+
}
172164
reject(error);
173165
return;
174166
}
175167

176168
effectiveSignal.addEventListener('abort', () => {
177169
if (!isResolved) {
178170
cleanup();
179-
const error = isTimeout
180-
? new TimeoutError('Service request', options.timeout, {
181-
entityType: 'service',
182-
entityName: this._serviceName,
183-
})
184-
: new AbortError('Service request', undefined, {
185-
entityType: 'service',
186-
entityName: this._serviceName,
187-
});
171+
const error = new Error(
172+
isTimeout
173+
? `Request timeout after ${options.timeout}ms`
174+
: 'Request was aborted'
175+
);
176+
error.name = isTimeout ? 'TimeoutError' : 'AbortError';
177+
if (isTimeout) {
178+
error.code = 'TIMEOUT';
179+
}
188180
reject(error);
189181
}
190182
});

test/test-rosidl-message-generator.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,6 @@ function buildTestMessage() {
6464
// Build the custom_msg_test package synchronously before running the test
6565
const customMsgTestPath = path.join(__dirname, 'custom_msg_test');
6666

67-
// List packages to ensure colcon can discover them
68-
require('child_process').spawnSync(
69-
'colcon',
70-
['--log-base', '/dev/null', 'list'],
71-
{
72-
cwd: customMsgTestPath,
73-
stdio: 'inherit',
74-
}
75-
);
76-
7767
const buildResult = require('child_process').spawnSync('colcon', ['build'], {
7868
cwd: customMsgTestPath,
7969
stdio: 'inherit',

0 commit comments

Comments
 (0)