0

I can't find any equivalent in Netsuite for fastcgi_finish_request();. I want to reply with code 200 right away to a 3rd party server call, but the suitelet/restlet should continue the execution.

the logic

/**
 * @NApiVersion 2.1
 * @NScriptType Suitelet
 */
define([],

    () => {
        /**
         * Defines the Suitelet script trigger point.
         * @param {Object} scriptContext
         * @param {ServerRequest} scriptContext.request - Incoming request
         * @param {ServerResponse} scriptContext.response - Suitelet response
         * @since 2015.2
         */
        const onRequest = (scriptContext) => {

            /**
             * set response code 200 and return the response
             * the equivalent of `fastcgi_finish_request` &  `session_write_close()` to close the session.
             * the 3rd party server should receive the response, but the NS script should continue
             */

            log.debug("code executed after 3rd party server received the suitelet response");
        }

        return { onRequest }

    });

Any Thoughts?

thx

fullstack.studio
  • 320
  • 1
  • 10

1 Answers1

0

For this sort of thing I write the payload to a queue record and trigger processing and do the quick return.

bknights
  • 14,408
  • 2
  • 18
  • 31
  • Thanks for the suggestion. The problem we have is to process a large number of orders via NS in a very short time. for example. We have "1 day latency" on Amazon for shipping. This means that all orders received before 2pm. must be shipped the same day. In this situation, I am not sure that putting the orders creation in queue is the optimal solution. – fullstack.studio Nov 15 '21 at 14:03
  • You can only do as many orders as Netsuite can handle anyway. There are various ways to 'fan out' the order creation once you have the specs. Feel free to PM me if you'd like to consult. My answer here: https://stackoverflow.com/questions/45448916/netsuite-restlet-write-performance-is-poor/45465658#45465658 offers some tips. – bknights Nov 15 '21 at 16:37
  • Yes, I understand and thank you for the advice offer. I've hit a lot of NS limits when we talk about "live events" and "transaction volume". I knew this question had an obvious NS answer "NO, it can't be done :)". I have to process an order by suitelet call, but as you know it can be really slow. thanks anyway. I think the solution will be to manage the queued calls outside of NS. – fullstack.studio Nov 15 '21 at 19:35