51Degrees / Device-Detection

THE Fastest and most Accurate device detection for C / PHP / Perl / Python and Node.js - professionally maintained device data
https://51degrees.com/device-detection
Other
112 stars 46 forks source link

Node.js Module stuck at provider.getMatch() on 3.2.18-dev #19

Closed prachaquanttech closed 7 years ago

prachaquanttech commented 7 years ago

Hi,

I'm 51degrees premium data customer. I'm found problem if call provider.getMatch() 5 times Node will stuck. It seems that If I increase poolSize to 10 It will stuck at 11th getMatch function call.

I'm using npm install fiftyonedegreescore@dev and run on node.js 8.6

Thank you

import * as fiftyonedegrees from 'fiftyonedegreescore'
const provider = fiftyonedegrees.provider({
  dataFile: '...',
  cacheSize: 10000,
  poolSize: 4,
})
provider.getMatch(ctx.header['user-agent'])
provider.getMatch(ctx.header['user-agent'])
provider.getMatch(ctx.header['user-agent'])
provider.getMatch(ctx.header['user-agent'])
provider.getMatch(ctx.header['user-agent']) // Process stuck here
Joseph51D commented 7 years ago

Hi @prachaquanttech

You will need to assign provider.getMatch() to a variable and then close the match object when you are finished with it:

var match = provider.getMatch(mobileUserAgent);
match.close();

-Joe

Joseph51D commented 7 years ago

Hi @prachaquanttech

Did this solve the issue?

Kind regards, Joe

prachaquanttech commented 7 years ago

Yes, The issue is solved.

Thank you