vldpyatkov commented on code in PR #10: URL: https://github.com/apache/ignite-nodejs-thin-client/pull/10#discussion_r3596306765
########## spec/cache/ColdComplexRead.spec.js: ########## @@ -0,0 +1,130 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +require('jasmine-expect'); + +const TestingHelper = require('../TestingHelper'); +const { + IgniteClientConfiguration, ObjectType, ComplexObjectType +} = require('apache-ignite-client'); + +const CACHE_NAME = '__test_cold_complex_read'; + +// Deadlock guard: a fresh client reading a complex object whose binary type is +// not yet in its own BinaryTypeStorage must issue a nested GET_BINARY_TYPE on the +// same socket from inside the get() payloadReader. If response finalization is +// awaited on the socket processing queue, that nested reply can never be parsed +// and get() hangs forever, so we race it against an explicit timeout. +const DEADLOCK_TIMEOUT_MS = 10000; + +class ColdValue { + constructor() { + this.id = null; + this.name = null; + } +} + +function coldValueType() { + return new ComplexObjectType(new ColdValue(), 'ColdValue'). + setFieldType('id', ObjectType.PRIMITIVE_TYPE.INTEGER). + setFieldType('name', ObjectType.PRIMITIVE_TYPE.STRING); +} + +function withTimeout(promise, ms, message) { + let timer; + const guard = new Promise((resolve, reject) => { + timer = setTimeout(() => reject(new Error(message)), ms); + }); + return Promise.race([promise, guard]).finally(() => clearTimeout(timer)); Review Comment: Promise.finally has to be rewritten. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
