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

[@azure/search-documents] span.context is not a function #17303

Closed
4 of 6 tasks
Ludovic71 opened this issue Aug 27, 2021 · 8 comments
Closed
4 of 6 tasks

[@azure/search-documents] span.context is not a function #17303

Ludovic71 opened this issue Aug 27, 2021 · 8 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Search

Comments

@Ludovic71
Copy link

  • Package Name: @azure/search-documents
  • Package Version: 11.2.0
  • Operating system: Windows
  • nodejs
    • version: 14.17.4
  • browser
    • name/version: Microsoft Edge Version 92.0.902.78 (Official build) (64-bit)
  • typescript
  • Is the bug related to documentation in

Describe the bug

import { SearchClient } from '@azure/search-documents';
...
const searchResults = await searchClient.search('*', searchOptions);

Will throw an exception as follows:

(node:28376) UnhandledPromiseRejectionWarning: TypeError: span.context is not a function
at TracingPolicy.<anonymous> (c:\repo\project\src\node_modules\@azure\core-http\src\policies\tracingPolicy.ts:79:32)
at step (c:\repo\project\src\node_modules\@azure\core-http\node_modules\tslib\tslib.js:143:27)
at Object.next (c:\repo\project\src\node_modules\@azure\core-http\node_modules\tslib\tslib.js:124:57)
at c:\repo\project\src\node_modules\@azure\core-http\node_modules\tslib\tslib.js:117:75
at new Promise (<anonymous>)
at Object.__awaiter (c:\repo\project\src\node_modules\@azure\core-http\node_modules\tslib\tslib.js:113:16)
at TracingPolicy.sendRequest (c:\repo\project\src\node_modules\@azure\core-http\dist\index.js:4430:22)
at ProxyPolicy.sendRequest (c:\repo\project\src\node_modules\@azure\core-http\src\policies\proxyPolicy.ts:158:29)
at OdataMetadataPolicy.<anonymous> (c:\repo\project\src\node_modules\@azure\search-documents\src\odataMetadataPolicy.ts:47:29)
at Generator.next (<anonymous>)
at c:\repo\project\src\node_modules\tslib\tslib.js:117:75
at new Promise (<anonymous>)
at Object.__awaiter (c:\repo\project\src\node_modules\tslib\tslib.js:113:16)
at OdataMetadataPolicy.sendRequest (c:\repo\project\src\node_modules\@azure\search-documents\dist\index.js:1871:22)
at SearchServiceClient.ServiceClient.sendRequest (c:\repo\project\src\node_modules\@azure\core-http\src\serviceClient.ts:303:25)
at SearchServiceClient.<anonymous> (c:\repo\project\src\node_modules\@azure\core-http\src\serviceClient.ts:518:34)
at step (c:\repo\project\src\node_modules\@azure\core-http\node_modules\tslib\tslib.js:143:27)
at Object.next (c:\repo\project\src\node_modules\@azure\core-http\node_modules\tslib\tslib.js:124:57)
at c:\repo\project\src\node_modules\@azure\core-http\node_modules\tslib\tslib.js:117:75
at new Promise (<anonymous>)
at Object.__awaiter (c:\repo\project\src\node_modules\@azure\core-http\node_modules\tslib\tslib.js:113:16)
at SearchServiceClient.ServiceClient.sendOperationRequest (c:\repo\project\src\node_modules\@azure\core-http\dist\index.js:4704:22)

To Reproduce
Steps to reproduce the behavior:

  1. Trying to repro in a smaller project was actually not possible, the small project worked as expected.
  2. Here is my current nodejs endpoint for reference
  3. Must be related to yarn.lock dependencies that are different from current node projet and smaller repro projet
import { FastifyPluginAsync } from 'fastify';
import S from 'fluent-json-schema';
import _ from 'lodash';
import { ISearchedAssetReply, SearchedAsset } from '../common/src/types';

import { SearchIndexClient, SearchClient, AzureKeyCredential, odata } from '@azure/search-documents';
import { SearchOptions } from '@azure/search-documents/types/search-documents';

interface IQuerystring {
  searchQuery: string;
}

const schema = {
  querystring: S.object().prop('searchQuery', S.string().required()),
};

// Getting endpoint and apiKey from .env file
const endpoint = '...';
const apiKey = '...';

export const handler: FastifyPluginAsync = async (fastify) => {
  fastify.get<{
    Querystring: IQuerystring;
    Reply: ISearchedAssetReply | string;
  }>('/api/search/assets2', { schema }, async (request, reply) => {
    let query = request.query;

    const indexName = 'assets';
    const searchClient = new SearchClient<SearchedAsset>(endpoint, indexName, new AzureKeyCredential(apiKey));

    let searchOptions: SearchOptions<keyof SearchedAsset> = {
      top: 10,
    };

    try {
      let searchResults = await searchClient.search('*', searchOptions);

      let totalCount = searchResults.count as number;
      const assets = searchResults.results; // FIXME async search iterator

      fastify.log.info(`Search assets for '${query.searchQuery}': assets.length=${assets}`);

      reply.status(200).send({
        assets,
        totalCount,
      });
    } catch (ex) {
      reply.status(400).send(ex);
    }
  });
};

Expected behavior
Should be able to get the searchResults object from searchClient.search() without any exception

Additional context
Unblocking solution: By using dev version @azure/search-documents: 1.3.0-alpha.20210816.1 the issue is gone !

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Aug 27, 2021
@ramya-rao-a
Copy link
Contributor

Thanks for the report @Ludovic71!

@maorleger Could this be because 11.2.0 of the search package is depending on 1.0.0-preview.11 of core-tracing? We ensured all of the other packages are on atleast 1.0.0-preview.12 or above.

@ramya-rao-a ramya-rao-a added Client This issue points to a problem in the data-plane of the library. Search labels Aug 27, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Aug 27, 2021
@harveyconnor
Copy link

I'm getting a similar issue with @azure/service-bus, see error below:

2021-08-27T02:48:35.237760198Z (node:24) UnhandledPromiseRejectionWarning: TypeError: messageSpan.spanContext is not a function
2021-08-27T02:48:35.237771999Z     at instrumentMessage (/app/node_modules/@azure/service-bus/dist/index.js:1873:74)
2021-08-27T02:48:35.237776099Z     at ServiceBusMessageBatchImpl.tryAddMessage (/app/node_modules/@azure/service-bus/dist/index.js:8617:42)
2021-08-27T02:48:35.237779399Z     at ServiceBusSenderImpl.sendMessages (/app/node_modules/@azure/service-bus/dist/index.js:8988:28)

@ramya-rao-a
Copy link
Contributor

@harveyconnor Can you please log a separate issue for the Service Bus package? Please include the version of the package you are using and a code snippet that we can use to replicate the issue

@harveyconnor
Copy link

Hi @ramya-rao-a thanks for the reply!
I have created a ticket here: #17307
Please let me know if you can help! Much appreciated!

@maorleger
Copy link
Member

Thanks for the report @Ludovic71!

@maorleger Could this be because 11.2.0 of the search package is depending on 1.0.0-preview.11 of core-tracing? We ensured all of the other packages are on atleast 1.0.0-preview.12 or above.

It does appear to be the case with 11.2.0 - it still depends on core-tracing preview.11 and core-http 1.2.6

I will work on getting a release out there as soon as possible.

@maorleger
Copy link
Member

@Ludovic71 @azure/[email protected] has been released which brings it up to @opentelemetry/api@^1.0.0 - please let me know if you continue to see that same issue.

@maorleger maorleger added the issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. label Sep 7, 2021
@ghost
Copy link

ghost commented Sep 7, 2021

Hi @Ludovic71. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

@ghost
Copy link

ghost commented Sep 14, 2021

Hi @Ludovic71, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

@ghost ghost closed this as completed Sep 14, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Search
Projects
None yet
Development

No branches or pull requests

4 participants