Hi there, can I pick someone's brain on the follow...
# suitescript
n
Hi there, can I pick someone's brain on the following? I'm working with an API has has very strict throttling limits. Even after batching requests, I'm still hitting the limits so I need a reliable way to add delays between calls without compromising performance (i.e. delays needs to be no longer than necessary). The solutions I've investigated/come across so far: 1. Use a 3rd party solution like EasyTimer.js: Errors due to dependencies not accessible on server-side. 2. Try to run a complex search to simulate the passing of time: (1) Imprecise (2) The query could always get indexed at some point and no longer run so slowly. 3. Call an API out there like Slowwly that produces a delay: Service might get discontinued without notice (incidentally, the site was down just now which proves the point). 4. Create my own delay service on AWS or elsewhere: Most attractive at this point but feels like an extra burden for something so "basic". Does anyone have another idea? Thanks.
b
choice 4 would be my favored solution
👍🏼 1
d
I created a super simply delay endpoint (using heroku). It takes a parameter called
delay
(in milliseconds). executes a 200 response using the
setTimeout
function.
n
@darrenhillconsulting Is your solution publicly available and guaranteed to stay in the air? Basically, can I use it for the foreseeable future?
d
Hmmm. Never considered allowing public usage. Let me ponder on that. I'd just want to ensure I'm not spending large $$$/monthly when doing that
n
Looking at heroku's free offering seems decent enough. That should be good enough
The app will go to sleep after 30 minutes of inactivity but since we're trying to simulate delays, that's not an issue... Give it a thought and let me know if you're willing to spun this since you already have an implementation. I'm willing to write about it 🙂 or get it set up if you can share the code/provide some guidance.
Actually I just noticed that Slowwly is OSS, just like Flash so I'm not sure there's much need for a new service. If they pull the sites down, we have the code to spun a new one...
s
I also vote for #4. And the implementation would be so trivial I don't see the need for using an existing service. Indeed I would expect deployment/monitoring of said service is a lot more work than writing it. I also noticed that Slowwly seems to want to call out to somewhere else (adding a delay) - which isn't what you're asking for? Just a service that creates a configurable delay should be like a single line of code?
👍🏼 1
d
I decided to open this up to the public. Its a simple service https://netsuite.extendapps.com/delay/[milliseconds] where you simply provide how long you want your delay in millliseconds. You'll notice that its 'https' ready, so no insecure warnings/errors from NetSuite
As you can see, this heroku instance is built to introduce tools for netsuite. We have other tools we may release along side this 'delay'. For example, replace the
User-Agent
header for inbound requests ... so you can 'webhookize' Suitelets
Did the above help @netsuite_insights?
n
Hi @darrenhillconsulting, you're the best! Yes this is excellent. And since it's from you, I can trust that it will be in the air forever (no pressure). 😉 Enqueued for a future blog post on NetSuiteInsights as promised.
d
Ya, we use it for our own solutions ... so, its not going anywhere
n
@stalbert You're right slowwly does more but all I need is a delay so Darren's solution is perfect.
s
yes, darren's is better 🙂
n
@darrenhillconsulting Thanks once again. As promised, I've published an article on this: https://netsuite.smash-ict.com/2021/03/learn-how-to-create-a-netsuite-server-side-script-sleep-delay/
👌 1
d
Thank you @netsuite_insights!